Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't TeamColor on touch working?

local parent = script.Parent
function steppedOn(part) 
if game.Players:GetPlayerFromCharacter(parent) then
	  parent.TeamColor = "Bright Green"
      parent.Humanoid.Health = 0
  end
end
script.Parent.Touched:connect(steppedOn)

So basically what I am trying to get it to do is when it is touched it changes your player to Team: "Level 2", and the Team Color is Bright Green. And then kills the player so it will get re-spawned at the next level. But I get no errors, and it doesn't seem to work. But If I take out the

parent.TeamColor =  "Bright Green"

then it will kill the player. So I can't really find out what is wrong with it. And help would be appreciated. :)

Thanks, Awesomespyhacker12

3 comments

0

where do you have the script

0

In a part in workspace

0

Isn't this a property of teams that is built into studio?

2 answers

✓ Accepted answer

Well, you used the TouchedEvent a bit wrong. I'll comment throughout my script!

script.Parent.Touched:connect(function(hit) -- The Touched Event
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then -- Checks if it's a player.
		local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Sets a variable for the player
		player.TeamColor = BrickColor.new("Bright green") -- Changes their Teamcolor to Bright green
		player.Character:BreakJoints() -- Another form of resetting their character
	end
end)
local parent = script.Parent
function steppedOn(part)
if game.Players:GetPlayerFromCharacter(parent) then
      parent.TeamColor = BrickColor.new("Bright green") -- Forgot to add BrickColor.new and green was capped
      parent.Humanoid.Health = 0
  end
end
script.Parent.Touched:connect(steppedOn)

Try that lol

2 comments

0

Nope doesn't work, and no errors either

0

OH Change Green to green

This discussion is preserved as it was. New answers, comments, and votes are closed.