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

Why is this teamchange/leaderboardchange script not working?

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)

1 answer

✓ Accepted answer

Make sure that script.Parent.color is a BrickColorValue

line 14 has "script.Parent.color.Color" which should be "script.Parent.color.Value"

3 comments

0

it also has script.Parent.color.BrickColor which should be value

0

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.

0

I actually feel dumb for making those mistakes.

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