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 make :LoadCharacter() FE?

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)

2 comments

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.

0

I did something like that, it changed the players team, but the player didn't spawn at the right spawn.

1 answer

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

1 comment

0

I did something like this, but when I respawn I stay at the regular spawn.

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