Hello! this is Jaison here and I was wondering if someone could help me fix my script. What I am trying to do in this script is when you touch a part you earn a point, but when you touch it again it wont give you a point here's the code:
local wins = game.Players.leaderstats.wins local player = game.Players.LocalPlayer local debounce = false local mouse = player:GetMouse() local G_ = script.Parent
G_.Touched:Connect(function(hit) while wait() do if hit.Parent == player.Character then if not debounce then debounce = true
wins.Value = wins.Value ~= 1 G_.TouchEnded:Connect(function() debounce = false end) end end end
You can DM me on discord JDev#4583
Try this:
function onTouch(hit) if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then char = game.Players:FindFirstChild(hit.Parent.Name) char.leaderstats.wins.Value +=1 script.Disabled = true end end script.Parent.Touched:Connect(onTouch)
Put it in a normal script in the brick you want. Oh also you dont need anything else