I need to detect if a player hit a part and then get that player and award them a "Star" in my game.
So far I've tried the code below, which gives the star(s) to every player in the game.
script.Parent.Touched:connect(function()
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("leaderstats") then
Player.leaderstats.Stars.Value = Player.leaderstats.Stars.Value + 1
end
end
end)
I tried some other things but they didn't work, this is the closest I've gotten.
Any amount of help is appreciated very much.

1 comment
Currently trying with a click detector instead.