Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Tool = script.Parent
- local Remote = Tool:WaitForChild("Remote")
- local mouseDown = false
- local tip = Tool.Tip
- local sound = Tool.Sound
- local Weld
- local Motor
- local MotorPart0
- local MotorPart1
- function getPlayer()
- return game:GetService("Players"):GetPlayerFromCharacter(Tool.Parent)
- end
- -------------------------------------------------------
- local attachment
- function mDown(target)
- mouseDown = true
- local H, max
- if target.Parent.Name == "Doorcontrol" then
- attachment = Instance.new("Attachment")
- attachment.Parent = target
- tip.Beam.Attachment1 = attachment
- max = 800
- target.Parent.Dynamics.Door.Value.BillBoardGui.Main.Health = 'Health: ' .. target.Parent.Dynamics.Door.Value.Parent.Health.Value .. '/800'
- H = target.Parent.Dynamics.Door.Value.Parent.Health
- return
- end
- tip.ParticleEmitter.Enabled = true
- tip.PointLight.Enabled = true
- sound:Play()
- while H and mouseDown and H.Value < max do
- H.Value = H.Value + 1
- wait()
- target.Parent.Dynamics.Door.Value.BillBoardGui.Main.Health = 'Health: ' .. target.Parent.Dynamics.Door.Value.Parent.Health.Value .. '/800'
- end
- end
- function mUp()
- mouseDown = false
- tip.ParticleEmitter.Enabled = false
- tip.PointLight.Enabled = false
- sound:Stop()
- if attachment then
- attachment:Destroy()
- end
- end
- -------------------------------------------------------
- function setPointDirection(position)
- local char = Tool.Parent
- if not char then return end
- if not Weld then
- Motor = char.Torso["Right Shoulder"]:Clone()
- MotorPart0 = char.Torso
- MotorPart1 = char["Right Arm"]
- Weld = Instance.new("Weld")
- Weld.Part0 = char.Torso
- Weld.Part1 = char["Right Arm"]
- Weld.C0 = CFrame.new(1, 1, 0)
- Weld.Parent = Weld.Part0
- end
- local jointPosition = Weld.Part0.CFrame:toWorldSpace(CFrame.new(1, 0.5, 0))
- local cframe = CFrame.new(jointPosition.p, position) * CFrame.Angles(math.pi/2, 0, 0) * CFrame.new(0, -1, 0)
- Weld.C0 = Weld.Part0.CFrame:toObjectSpace(cframe)
- end
- function onRemote(player, func, ...)
- if player ~= getPlayer() then return end
- if func == "UpdateDirection" then
- --setPointDirection(...)
- elseif func == "Down" then
- mDown(...)
- elseif func == "Up" then
- mUp()
- end
- end
- function onUnequipped()
- if Weld then
- Weld:Destroy()
- Weld = nil
- end
- if Motor then
- Motor.Part0 = MotorPart0
- Motor.Part1 = MotorPart1
- Motor.Parent = MotorPart0
- Motor = nil
- end
- end
- Remote.OnServerEvent:connect(onRemote)
- --Tool.Unequipped:connect(onUnequipped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement