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

How do I fix this team changer script for a team change GUI?

Currently my scriptI wrote to change teams is not working, here is what it looks like:

(line 1) local plr = game.Players.LocalPlayer (line 2) script.Parent.Mousebutton1Click:Connect(function() (line 3) plr.TeamColor = BrickColor.new.('Rust') (line 4) wait (1) (line 5) plr.Health = 0 (line 6) end)

1 comment

0

This is so confusing because you didn't format your code. I'm litteraly about to open notepad and format it myself.

2 answers

I've never seen this many errors in somebody's code in a long long time.

But anyways the first error is on line 2 you typed MouseButton1Click with a lowercase b.

It should be like this:

script.Parent.MouseButton1Click:Connect(function()

The second error is that on line 3 you messed up on BrickColor.new. You used a single apostrophe instead of two. You also added an additional dot after .new.

It should be like this:

plr.TeamColor = BrickColor.new("Rust")

The third error is on line 5. There is not a health property inside of the player class on Roblox. Although, there is a health property inside of the players Humanoid. To fix this you would simply replace it with the following:

plr.Character.Humanoid.Health = 0 

The FOURTH error is that you are not defining what the variable plr is calling. You are going to want to insert a new line of code at the very top of the script and make it the following:

plr = game.Players.LocalPlayer

Anyways, hopefully this helped.

1 comment

0

Not bad, upvote! Although you probably should explain that changing TeamColor property is not gonna do anything if there are no teams. But hey at least it's not looking like a hell for developers

  1. Your first error is on line 2, you put script.Parent.Mousebutton1Click, you messed up on the spelling it should be a capital B script.Parent.MouseButton1Click

  2. Your second error is on line 5, doing plr.health will not get the health you would have to plr.Character.Health = 0

Here is what I have done and I tested it to make sure it works!

local plr = game.Players.LocalPlayer
NewTeamColor = "Rust"

function TeamChange()
	plr.TeamColor = BrickColor.new(NewTeamColor)
	wait(1)
	plr.Character.Humanoid.Health = 0 
end

script.Parent.MouseButton1Click:Connect(TeamChange)

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