Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RunService = game:GetService("RunService")
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local Mouse = Player:GetMouse()
- local Tool = script.Parent
- local RemoteEvent = Tool:WaitForChild("RemoteEvent")
- local GunConfig = Tool:WaitForChild("Configuration")
- local Activated = false
- local Heartbeat
- function Fire()
- RemoteEvent:FireServer(Mouse.Hit.Position)
- end
- Tool.Activated:Connect(function()
- Activated = true
- if GunConfig:WaitForChild("IsAutomatic").Value == true then
- Heartbeat = RunService.Heartbeat:Connect(function()
- if Activated then
- Fire()
- else
- Heartbeat:Disconnect()
- end
- end)
- else
- RemoteEvent:FireServer(Mouse.Hit.Position)
- end
- end)
- Tool.Deactivated:Connect(function()
- task.delay(.01,function()
- if Activated then
- Activated = false
- end
- end)
- end)
- Tool.Unequipped:Connect(function()
- Activated = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment