Currently i made a new script for my cookie clicker game and i don't understand, when im clicking on the cookie with the script all the players in the server gets a cookie? How do i make it a certain player who clicks it gets the cookie?
debounce = false
function onClick(Player)
if not debounce then
debounce = true
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:findFirstChild("leaderstats") then
Player.leaderstats.Cookies.Value = Player.leaderstats.Cookies.Value +1
wait(0.1)
debounce = false
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

2 comments
Is this in a LocalScript?
nope