Problem:
You have the concept of what you are trying to do correctly but you just did not type the code correctly. Which is understandable as you may be learning and the learning process is awesome yet also daunting at times. I do not know why you have lines 2-4 as it seems you are trying to assign them to that team, but you said that you just wanted them to respawn if not on that team so I will leave that alone.
Solution:
Since you have the concept correct it is pretty straightforward from here. Whenever you want to use a ServerScript to find a player through a Touch event to find their team you would use the :GetPlayerFromCharacter() method, which is what you did. The thing is you would also need to do a for loop to achieve this result and do if statements to check. As I did below:
Script:
local debounce = true
script.Parent.Touched:Connect(function(hit)
if debounce == true then
print("debounce is turning off")
debounce = false
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
for i,v in pairs(game.Players:GetPlayers()) do
if v.Name == player.Name then
print("Found player "..v.Name)
if v.TeamColor ~= BrickColor.new("Really red") then
print("Not in this team")
v:LoadCharacter()
debounce = true
else
print("You are on this team")
debounce = true
end
end
end
end
end)
If you have any problems or you do not understand anything do not be afraid to ask. If this helped you do not forget to give an upvote and accept my answer.
1 comment
http://wiki.roblox.com/index.php?title=API:Class/Team/GetPlayers