✓ Accepted answer
You have multiple problems with this script. One being, you need a LocalScript to do this (Ignoring errors that would occur) but I will show you how with a regular script.
First, here's our working code to change the team:
local db = false
function onTouch(part)
if part.Parent.Humanoid then
if db == false then db = true
local Player = game.Players:GetPlayerFromCharacter(part.Parent)
Player.TeamColor = BrickColor.new("Black")
wait(1)
db = false
end
end
end
script.Parent.Touched:connect(onTouch)
Now, you were using LocalScript ONLY things such as LocalPlayer, which would not work in our Script. So instead we need to find out who the person that touched the brick is so we can change their team. To do this we need to use the function :GetPlayerFromCharacter() yet in the parenthesis we must tell whose character touched it. We use 'part.Parent' because the part is what touched it and the Parent is the character.
You will also I changed Teams differently. I'm not sure where you got that way from, but to do this we must change the TeamColor of the player. This TeamColor can be found in the properties of a Player. Changing the TeamColor is just liked changing a BrickColor, you must do `BrickColor.new()' to do this. In my script I made it Black, you must change Black to the color of the team you want.
You are using Debounce incorrectly plus I don't even see the variable of Debounce to be used. First you must set up the variable like I did for db = false and then, later on in the script you need to change it to true so the script will not run it multiple times until db = false.
If you have question, comment on this Answer. Accept if this helped!
3 comments
Apparently using Tab made my word in Lua Form. Strange, but I fixed it.
Thank you for helping! As I new to scripting, A Big thanks to you! :)
Np, As I have resolution problems, I comment SUPA slow.