I'm making a game where you can slap people, and when you do, you get 1 point from it. There is a problem though. It is detecting a slap multiple times giving a lot more points than it should be.
Any help would be nice.
Here is my script. It's a local script btw.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://4617501015"
local play = player.Character.Humanoid:LoadAnimation(animation)
play:Play()
script.Parent.Parent.Character["Right Arm"].Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
wait()
hit.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
script.Parent.Parent.leaderstats.Slaps.Value = script.Parent.Parent.leaderstats.Slaps.Value + 1
script.Parent.Parent.leaderstats.Coins.Value = script.Parent.Parent.leaderstats.Coins.Value + math.random(2,7)
end
end)
end)

1 comment
Thanks! I don't know how I didn't think of this.