This script is supposed to change team and leader board stats once a brick is touched. It works in studio but when I test in game it only kills u which is what is supposed to be done if the team spots are taken.
here it is:
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
chr = hit.Parent
plr = game.Players:FindFirstChild(chr.Name)
if plr and chr then
if script.Parent.Parent.Name == "Curator: no one" then -- The brick has this because it has a Humanoid to display "Curator: no one" until touched
if plr.TeamColor == BrickColor.new('Pearl') then -- a neutral team
plr.TeamColor = script.Parent.color.Value -- change TeamColor
script.Parent.stringval.Value = chr.Name -- StringValue in brick becomes player's name
plr.leaderstats.Job.Value = "Owner"
script.Parent.Parent.Name = "Owner: " .. chr.Name -- changes Brick Name
end
elseif script.Parent.Parent.Name ~= "Curator: no one" then -- if the name is not "Curator: no one"
if plr.TeamColor ~= script.Parent.color.Color and plr.TeamColor ~= script.Parent.color.BrickColor then
chr.Humanoid.Health = 0 -- kills player if they are not neutral and not on the teamcolors for this brick
end
end
end
end
end)

3 comments
it also has script.Parent.color.BrickColor which should be value
Thank you! The main error was in that poorly written if statement using BrickColor and Color. I was tired when I wrote it but I see how I messed up.
I actually feel dumb for making those mistakes.