I used that script on a brick but it didn't work:
script.Parent.Touched:connect(function(hit) Local player = hit.Parent.Name game.Players.player.Team = LabLabLab --Lol
I used that script on a brick but it didn't work:
script.Parent.Touched:connect(function(hit) Local player = hit.Parent.Name game.Players.player.Team = LabLabLab --Lol
"connect" is deprecated, player.Team requires an object, and game.Players.Player would be an object when the variable player is simply a string
(saw a comment after posting, edited to use more reliable method)
script.Parent.Touched:Connect(function(hit)
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
user.Team = game:GetService('Teams'):FindFirstChild('Team1')
end)
Using FindFirstChild o find a player is unreliable, as anything with the same name as the player could go in Players
@incapaz you're right (though anything other than a player being in players would be stupid) it's better to use getplayerfromcharacter
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
script.Parent.Touched:connect(function(hit) game.Players:GetPlayerFromCharacter(hit.Parent).Team = LabLabLab end)