Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local control = script.Parent -- gui
- local mouse = game:GetService("Players").LocalPlayer:GetMouse() -- mouse
- local remote = control:WaitForChild("DAMNFIRE") -- remote event
- local uis = game:GetService("UserInputService") -- input service (detect key pressed)
- local holding = false
- uis.InputBegan:Connect(function(i,x) -- uis keypressed function
- if not x then -- check if player is not typing in chat or in a gui
- if i.KeyCode == Enum.KeyCode.F then -- check if the player has pressed the button
- holding = true
- remote:FireServer("START")
- while true do
- if holding then
- remote:FireServer("HOLDING")
- else
- break
- end
- task.wait()
- end
- end
- end
- end)
- uis.InputEnded:Connect(function(i,x)
- if not x then
- if i.KeyCode == Enum.KeyCode.F then
- task.wait(.1)
- holding = false
- remote:FireServer("FIRE",mouse.Hit.Position)
- print("released")
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement