Hello, I am trying to make a script make a player change teams on touch, I keep getting errors.
local Debounce = false
script.Parent.Touched:Connect(function(h)
if not Debounce then
Debounce = true
game.Players:GetPlayerFromCharacter(h.Parent).Team = game.Teams.Nintendo
wait(10.0)
Debounce = false
end
end)
local Players = game:GetService("Players")
local Debounce = false
script.Parent.Touched:Connect(function(h)
if not Debounce then
Debounce = true
game.Players:GetPlayerFromCharacter(h.Parent).Team = game.Teams.Nintendo
wait(10.0)
Debounce = false
end
end)
Try adding Players above
What error is it returning?
Hello, make sure the player isn’t nil first, you can do that by just creating a variable for player and then checking it.
I’ve done this and It’s working completly fine for me.
local Debounce = false
script.Parent.Touched:Connect(function(h)
if not Debounce then
Debounce = true
local player = game.Players:GetPlayerFromCharacter(h.Parent)
if player then
player.Team = game.Teams.Nintendo
end
wait(10.0)
Debounce = false
end
end)
Hey, I’m new to DevForum and had a question. I would of made a post but that would of got me warned for wrong topic so I didn’t know where or who to ask but how do I post “Builder” next to my name?
Yes but play it with 2 players. It will tell you the other player is on a team meanwhile the other player has something different. It’s hard to tell if it is because I am using Beta Studio and it might be broken.