I have no clue if I'm even starting this in the right direction. Here's the script I'm trying and more information at bottom.
SP = script.Parent SP.Touched:connect(function(hit) local info = Parent.Parent.Players.LocalPlayer.TeamColor --local team = if hit.info == "Br. yellowish green" then hit.info = "Bright yellow" end end)
It was in a Local script, But turns out a touch interest would not form so this is in a Script. Yes, I know that I cannot use LocalPlayer for regular scripts. What I mean to do is check the players team, if they are in a certain team, then change their team to a different one. But, say you finished the obby, the script wouldn't work backwards or to change your team at all. Please help, At the least push me in the right direction? Is there a way to look for the name of the players team so I don't have a max of 64 spawns instead of looking for team color with a max of 64 spawns?
You can't use the Touched event in a local script or use local player in a server-side script.
Use :GetPlayerFromCharacter()
to find the player. Also, another mistake you had was that you said, "hit.info
" When info was a variable which isn't in hit
.
SP = script.Parent --Regular Script, not local SP.Touched:connect(function(hit) local info = game.Players:GetPlayerFromCharacter(hit.Parent) if info.TeamColor == "Br. yellowish green" or "Bright red" then --You can use "or" in an if then statement like, "if the sky is cloudy or it's raining then I won't go outside" so if it's either cloudy OR raining you won't go outside. You can use and too. "if it's windy outside and it's snowing then I'll stay inside", If it's just snowing, you'll go outside. If it's just windy, you'll go outside, but If it's BOTH, you'll stay inside. -- You can't just say bob = "Blue", you need to say something like bob.Value = "Blue". info.TeamColor = "Bright yellow" --Change the team color. end end)
To add onto LordDragonZord's answer. The TeamColor
of a player returns a BrickColor
so we have to compare it to a BrickColor
and not a string
.
SP = script.Parent SP.Touched:connect(function(hit) local info = game.Players:GetPlayerFromCharacter(hit.Parent) if info.TeamColor == BrickColor.new("Br. yellowish green") then info.TeamColor = BrickColor.new("Bright Yellow") end end)