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

How do I make :LoadCharacter() FE?

Asked by 6 years ago

So I'm making a team change gui, and being a beginner scripter it's not easy for me to make things FE.

If anyone has any idea how to turn this into FE, please help

local button = script.Parent
local player = game.Players.LocalPlayer

button.MouseButton1Click:connect(function()
    if player:IsInGroup(3761159) then
        player.TeamColor = BrickColor.new("Bright red")
        player:LoadCharacter()
    end
end)
0
You will need to move the validation code onto a script with a remote event to allow the server to change the players team and load the character. The client should only ask the server to chaneg the team. User#5423 17 — 6y
0
I did something like that, it changed the players team, but the player didn't spawn at the right spawn. OfficialMiles 0 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

For scripting with FE, you'll need to use Remote Events a lot of the time. If you aren't familiar with those, you can read more about them here: http://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

I would suggest making it so when you click the button, it fires an event to a server script, and when the server script receives the remote event, it will change that player's team.

something like this:

Local Script ~

    local button = script.Parent
    local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

    button.MouseButton1Click:connect(function()
    remoteEvent:FireServer()
    end)

Server Script ~

    local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

    remoteEvent.OnServerEvent:connect(function(player)
        if player:IsInGroup(3761159) then
            player.TeamColor = BrickColor.new("Bright red")
            player:LoadCharacter()
    end
end
0
I did something like this, but when I respawn I stay at the regular spawn. OfficialMiles 0 — 6y
Ad

Answer this question