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

How can i make this team changer script change your team and your character?

Asked by 7 years ago
Edited 7 years ago
local Player = game.Players.LocalPlayer
local groups = {1198534}

function Click()
    for i, ID in pairs(groups) do
        if Player:IsInGroup(ID) then
            Player.TeamColor = BrickColor.new("Bright red")
            Player:LoadCharacter()
            break
        end
    end
end

script.Parent.MouseButton1Down:connect(Click)

I'm trying to make a team script where instead of it killing you it just respawns you instead. However it only changes your team and doesn't respawn. How can i fix?

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

For the function :LoadCharacter() to work, you must be using a server-script, and by your Line 1 defining player as game.Players.LocalPlayer, it seems to me your using a LocalScript

At the moment, my best solution I can give you off the top of my head is to do this (Not The Best): Move it all to a ServerScript, then define Player through going through a script.Parent pathway,

^ That should work if your script is in a button, which is in a frame/gui, which is in the startergui area.

One example: Your Button/Script Location:

game.Players.Player1.PlayerGui.ScreenGui.TextButton.Script

Now you would have to get to Player1 in that path Use this:

local Player = script.Parent.Parent.Parent.Parent

Like I said, not the best, so try and find a better solution to your problem. Anyways, Hope this helps, Good luck

For more information, use this wiki article

Ad

Answer this question