Hello,
I have a tool that gives you cash when you click, but how do I make it so that players can hold-click the tool to get cash (just like in simulator games)?
Here is my script:
local tool = script.Parent
local Handle = tool.Handle
local CashValue = tool:WaitForChild("CashValue").Value
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.Remotes:WaitForChild("GiveCashEvent")
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local ShakeAnim = Humanoid:LoadAnimation(script.Parent:WaitForChild("ShakeAnim"))
local debounce = false
tool.Activated:Connect(function()
if not debounce then
debounce = true
ShakeAnim:Play()
Event:FireServer(CashValue)
wait(0.6)
debounce = false
end
end)
tool.Unequipped:Connect(function()
ShakeAnim:Stop()
end)
Thank you for your time!

2 comments
put the cash value in the normal script, exploiters can just change the cashvalue to something like math.huge and get infinite coins
Cash value is how much money a player gets with each click.