Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't TeamColor on touch working? [closed]

Asked by 9 years ago
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

0
where do you have the script davness 376 — 9y
0
In a part in workspace BinaryResolved 215 — 9y
0
Isn't this a property of teams that is built into studio? Antharaziia 75 — 9y

Locked by YellowoTide, ImageLabel, and NotsoPenguin

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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)
Ad
Log in to vote
-1
Answered by 9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
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

0
Nope doesn't work, and no errors either BinaryResolved 215 — 9y
0
OH Change Green to green xXUltraAltraXx 20 — 9y