I wrote a script that basically worked so that every time a player clicked on a specific part, it would give them one point. The part would change color, and there would be a 3 second cool down. However, when I tried testing it with 3 players, the points were only being assigned to Player1, regardless whether it was Player2 or Player3 that actually clicked the part. Here is the code I have below:
--leaderboard script
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"
local points = Instance.new("IntValue", stats)
points.Name = "Points"
points.Value = 0
end)
-- script for the part that the player clicks
script.Parent.BrickColor = BrickColor.new("Bright green")
enabled = false
script.Parent.ClickDetector.MouseClick:connect(function()
if enabled == false then
enabled = true
script.Parent.BrickColor = BrickColor.new("Really red")
local player = game.Players:FindFirstChildOfClass("Player")
local points = player.leaderstats.Points
points.Value = points.Value + 1
wait(3)
script.Parent.BrickColor = BrickColor.new("Bright green")
enabled = false
end
end)
Help would be very much appreciated, thanks!

3 comments
Your also picking Player 1 since your letting the script pick with Players:FindFirstChildOfClass, the first child it finds with that class it will pick and roblox likes to alphabetically assign them them number assign Xx_XSanderPlayXx has the perfect answer to it
Yeah true
Yes, this worked very well! Thank you!