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

Help with team change gui?

Asked by 8 years ago

Error: LoadChracter is not a valid member of Player

It works, I just get this error, and it makes me have to click it twice to respawn.

local clicker = game.Players.LocalPlayer

script.Parent.MouseButton1Down:connect(function()
    if clicker.TeamColor == BrickColor.new("Bright red") then
        clicker.TeamColor = BrickColor.new("Bright blue")
        clicker:LoadChracter()
    end
end)

1 answer

Log in to vote
2
Answered by 8 years ago

First problem player.TeamColor takes a BrickColor value not a string

BrickColor.new("Bright blue")

Second problem the parameters of MouseButton1Down are x, y not the player that clicks it.

MouseButton1Down should be used in a local script since so you can get the person who clicked with localplayer

local clicker = game.Players.LocalPlayer

Third problem Humanoid isn't in the player, it's in the character

local clicker = game.Players.LocalPlayer
local character = clicker.Character

Fixed code put together

local clicker = game.Players.LocalPlayer
local character = clicker.Character

script.Parent.MouseButton1Down:connect(function()
    if clicker.TeamColor == BrickColor.new("Bright blue") then
        clicker.TeamColor = BrickColor.new("Bright red")
        clicker.Humanoid.Health = 0
    end
end)
Ad

Answer this question