Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When you touch a part it adds a point, but when you touch it again it wont give you a point?

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

end)

You can DM me on discord JDev#4583

1 comment

0

can you please edit it and format it properly, i might be able to help then

1 answer

✓ Accepted answer

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

1 comment

0

tysm dude!

This discussion is preserved as it was. New answers, comments, and votes are closed.