Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Name: Ruler
- Made by: Hattozo
- Description: i know baldi basics is pretty much dead at this point but I wanted to make this
- ]]--
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Script1 = Instance.new("Script")
- LocalScript2 = Instance.new("LocalScript")
- RemoteEvent3 = Instance.new("RemoteEvent")
- SpecialMesh4 = Instance.new("SpecialMesh")
- Animation5 = Instance.new("Animation")
- Camera6 = Instance.new("Camera")
- Part7 = Instance.new("Part")
- SpecialMesh8 = Instance.new("SpecialMesh")
- Decal9 = Instance.new("Decal")
- Sound10 = Instance.new("Sound")
- Sound11 = Instance.new("Sound")
- Tool0.Name = "Ruler"
- Tool0.Parent = mas
- Tool0.Grip = CFrame.new(-0.300000012, 0.100000001, 0, 0, -0.897135317, -0.441755891, 0.992277861, -0.0547930822, 0.111275934, -0.124034733, -0.438344657, 0.890207469)
- Tool0.GripForward = Vector3.new(0.441755891, -0.111275934, -0.890207469)
- Tool0.GripPos = Vector3.new(-0.300000012, 0.100000001, 0)
- Tool0.GripRight = Vector3.new(0, 0.992277861, -0.124034733)
- Tool0.GripUp = Vector3.new(-0.897135317, -0.0547930822, -0.438344657)
- Script1.Name = "Server"
- Script1.Parent = Tool0
- table.insert(cors,sandbox(Script1,function()
- local Tool = script.Parent
- local Remote = Tool:WaitForChild("Remote")
- local Handle = Tool:WaitForChild("Handle")
- local FriendlyFire = false
- --local ArmMesh
- local HitAble = false
- local HitWindup = 0.15
- local HitWindow = 0.75
- local HitDamage = 15
- local HitVictims = {}
- local SwingAble = true
- local SwingRestTime = 1
- --returns the wielding player of this tool
- function getPlayer()
- local char = Tool.Parent
- return game:GetService("Players"):GetPlayerFromCharacter(char)
- end
- --helpfully checks a table for a specific value
- function contains(t, v)
- for _, val in pairs(t) do
- if val == v then
- return true
- end
- end
- return false
- end
- --tags a human for the ROBLOX KO system
- function tagHuman(human)
- local tag = Instance.new("ObjectValue")
- tag.Value = getPlayer()
- tag.Name = "creator"
- tag.Parent = human
- game:GetService("Debris"):AddItem(tag)
- end
- --used by checkTeams
- function sameTeam(otherHuman)
- local player = getPlayer()
- local otherPlayer = game:GetService("Players"):GetPlayerFromCharacter(otherHuman.Parent)
- if player and otherPlayer then
- if player == otherPlayer then
- return true
- end
- if otherPlayer.Neutral then
- return false
- end
- return player.TeamColor == otherPlayer.TeamColor
- end
- return false
- end
- --use this to determine if you want this human to be harmed or not, returns boolean
- function checkTeams(otherHuman)
- return not (sameTeam(otherHuman) and not FriendlyFire)
- end
- function onTouched(part)
- if part:IsDescendantOf(Tool.Parent) then return end
- if not HitAble then return end
- if part.Parent and part.Parent:FindFirstChild("Humanoid") then
- local human = part.Parent.Humanoid
- if contains(HitVictims, human) then return end
- local root = part.Parent:FindFirstChild("HumanoidRootPart")
- if root and not root.Anchored then
- local myRoot = Tool.Parent:FindFirstChild("HumanoidRootPart")
- if myRoot and checkTeams(human) then
- local delta = root.Position - myRoot.Position
- human.Sit = true
- tagHuman(human)
- human:TakeDamage(HitDamage)
- table.insert(HitVictims, human)
- local bv = Instance.new("BodyVelocity")
- bv.maxForce = Vector3.new(1e9, 1e9, 1e9)
- bv.velocity = delta.unit * 128
- bv.Parent = root
- game:GetService("Debris"):AddItem(bv, 0.05)
- Handle.Smack.Pitch = math.random(90, 110)/100
- Handle.Smack.TimePosition = 0.15
- Handle.Smack:Play()
- end
- end
- end
- end
- --[[function onEquip()
- local char = Tool.Parent
- local arm = Tool.ArmMesh:Clone()
- arm.Parent = char:FindFirstChild("Right Arm")
- ArmMesh = arm
- end
- function onUnequip()
- if ArmMesh then
- ArmMesh:Destroy()
- ArmMesh = nil
- end
- end
- ]]
- function onLeftDown()
- if not SwingAble then return end
- SwingAble = false
- delay(SwingRestTime, function()
- SwingAble = true
- end)
- delay(HitWindup, function()
- HitAble = true
- delay(HitWindow, function()
- HitAble = false
- end)
- end)
- HitVictims = {}
- Remote:FireClient(getPlayer(), "PlayAnimation", "Swing")
- wait(0.25)
- Handle.Boom.Pitch = math.random(80, 100)/100
- Handle.Boom:Play()
- end
- function onRemote(player, func, ...)
- if player ~= getPlayer() then return end
- if func == "LeftDown" then
- onLeftDown(...)
- end
- end
- Tool.Equipped:connect(onEquip)
- Tool.Unequipped:connect(onUnequip)
- Handle.Touched:connect(onTouched)
- Remote.OnServerEvent:connect(onRemote)
- end))
- LocalScript2.Name = "Client"
- LocalScript2.Parent = Tool0
- table.insert(cors,sandbox(LocalScript2,function()
- local Player = game:GetService("Players").LocalPlayer
- local UIS = game:GetService("UserInputService")
- local Mouse = Player:GetMouse()
- local Tool = script.Parent
- local Remote = Tool:WaitForChild("Remote")
- local Tracks = {}
- local InputType = Enum.UserInputType
- local BeganConnection, EndedConnection
- function playAnimation(animName, ...)
- if Tracks[animName] then
- Tracks[animName]:Play()
- else
- local anim = Tool:FindFirstChild(animName)
- if anim and Tool.Parent and Tool.Parent:FindFirstChild("Humanoid") then
- Tracks[animName] = Tool.Parent.Humanoid:LoadAnimation(anim)
- playAnimation(animName, ...)
- end
- end
- end
- function stopAnimation(animName)
- if Tracks[animName] then
- Tracks[animName]:Stop()
- end
- end
- function inputBegan(input)
- if input.UserInputType == InputType.MouseButton1 then
- Remote:FireServer("LeftDown")
- end
- end
- function inputEnded(input)
- if input.UserInputType == InputType.MouseButton1 then
- Remote:FireServer("LeftUp")
- end
- end
- function onRemote(func, ...)
- if func == "PlayAnimation" then
- playAnimation(...)
- elseif func == "StopAnimation" then
- stopAnimation(...)
- end
- end
- function onEquip()
- BeganConnection = UIS.InputBegan:connect(inputBegan)
- EndedConnection = UIS.InputEnded:connect(inputEnded)
- end
- function onUnequip()
- if BeganConnection then
- BeganConnection:disconnect()
- BeganConnection = nil
- end
- if EndedConnection then
- EndedConnection:disconnect()
- EndedConnection = nil
- end
- end
- Tool.Equipped:connect(onEquip)
- Tool.Unequipped:connect(onUnequip)
- Remote.OnClientEvent:connect(onRemote)
- end))
- RemoteEvent3.Name = "Remote"
- RemoteEvent3.Parent = Tool0
- SpecialMesh4.Name = "ArmMesh"
- SpecialMesh4.Parent = Tool0
- SpecialMesh4.MeshId = "http://www.roblox.com/asset/?id=54531127"
- SpecialMesh4.TextureId = "http://www.roblox.com/asset/?id=54530630"
- SpecialMesh4.MeshType = Enum.MeshType.FileMesh
- Animation5.Name = "Swing"
- Animation5.Parent = Tool0
- Animation5.AnimationId = "rbxassetid://243827693"
- Camera6.Name = "ThumbnailCamera"
- Camera6.Parent = Tool0
- Camera6.CFrame = CFrame.new(-10.3037863, 39.3394203, -3.54806352, 0.0205491576, 0.0850573629, 0.996164203, 1.16415322e-10, 0.996374667, -0.0850753263, -0.99978888, 0.00174822635, 0.0204746593)
- Camera6.CoordinateFrame = CFrame.new(-10.3037863, 39.3394203, -3.54806352, 0.0205491576, 0.0850573629, 0.996164203, 1.16415322e-10, 0.996374667, -0.0850753263, -0.99978888, 0.00174822635, 0.0204746593)
- Camera6.FieldOfView = 20
- Camera6.Focus = CFrame.new(-12.2961159, 39.5095711, -3.58901286, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Camera6.focus = CFrame.new(-12.2961159, 39.5095711, -3.58901286, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part7.Name = "Handle"
- Part7.Parent = Tool0
- Part7.CFrame = CFrame.new(12.1999998, 2.41700006, 1.70000005, 8.74227766e-08, -1, -7.57103464e-08, -0.866025388, -3.78551732e-08, -0.5, 0.5, 1.09278474e-07, -0.866025388)
- Part7.Orientation = Vector3.new(30, -180, -90)
- Part7.Position = Vector3.new(12.1999998, 2.41700006, 1.70000005)
- Part7.Rotation = Vector3.new(150, 0, 90)
- Part7.Color = Color3.new(0.388235, 0.372549, 0.384314)
- Part7.Transparency = 1
- Part7.Size = Vector3.new(1, 0.800000012, 5)
- Part7.BottomSurface = Enum.SurfaceType.Smooth
- Part7.BrickColor = BrickColor.new("Dark stone grey")
- Part7.TopSurface = Enum.SurfaceType.Smooth
- Part7.brickColor = BrickColor.new("Dark stone grey")
- Part7.FormFactor = Enum.FormFactor.Plate
- Part7.formFactor = Enum.FormFactor.Plate
- SpecialMesh8.Parent = Part7
- SpecialMesh8.MeshId = "http://www.roblox.com/asset/?id=10547612"
- SpecialMesh8.Scale = Vector3.new(1.79999995, 1.79999995, 1.79999995)
- SpecialMesh8.TextureId = "rbxassetid://2231166057"
- SpecialMesh8.MeshType = Enum.MeshType.FileMesh
- Decal9.Parent = Part7
- Decal9.Texture = "http://www.roblox.com/asset/?id=2231166057"
- Decal9.Face = Enum.NormalId.Right
- Sound10.Name = "Boom"
- Sound10.Parent = Part7
- Sound10.Pitch = 0.88999998569489
- Sound10.PlaybackSpeed = 0.88999998569489
- Sound10.SoundId = "rbxassetid://1804495872"
- Sound10.Volume = 1
- Sound11.Name = "Smack"
- Sound11.Parent = Part7
- Sound11.SoundId = "rbxassetid://155363126"
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = game:GetService("Players").LocalPlayer.Backpack
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement