So I want the player to receive +1 win when touching a brick, but I can't seem to make it work
script.Parent.Touched:Connect(function(Player)
local ls = Player.leaderstats
if ls then
ls.Wins.Value = ls.Wins.Value + 1
end
end)
So I want the player to receive +1 win when touching a brick, but I can't seem to make it work
script.Parent.Touched:Connect(function(Player)
local ls = Player.leaderstats
if ls then
ls.Wins.Value = ls.Wins.Value + 1
end
end)
Normally, another part can touch that part and trigger the Touched event and make the connected function assume that the part that was touched is the player; That'll not work, also the player object will not be the one that triggers the event and is returned, a part of the player's character does that.
You can use Players:GetPlayerFromCharacter, which is self-explanatory:
script.Parent.Touched:Connect(function(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
-- add stats
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.