How can I make this script show on the server?

  1. What do you want to achieve? A character selection screen.

  2. What is the issue? I have a code that works, but it has recently come to my attention that the script is only client side, meaning that no one else sees the new character aside from the client itself.

  3. What solutions have you tried so far? I’ve tried having remote events fire to the server that should have handled the character changing but it has either killed the character or made the camera stuck in the character selection area without the new character even spawning.

here’s the character setting script (local script under the button):

local Button = script.Parent.ImageButton
local player = game.Players.LocalPlayer

local replicatedStorage = game:GetService("ReplicatedStorage")

local SetSubject = replicatedStorage.CharacterSelection.SetSubject

local CharacterGUI = script.Parent.Parent.Parent


Button.MouseButton1Down:Connect(function()
	CharacterGUI.Enabled = false
	local ChosenCharacter = replicatedStorage.CharacterSelection.Characters.Daisy:Clone()
	ChosenCharacter.Humanoid.DisplayName = "  "
	local CurrentCharacter = player.Character
	local LocalScripts = {}

	CurrentCharacter.Health:Clone().Parent = ChosenCharacter
	table.insert(LocalScripts,CurrentCharacter.Animate:Clone())     
	ChosenCharacter.Parent = workspace
	player.Character = ChosenCharacter
	for index2,item2 in pairs(LocalScripts) do
		item2.Parent = ChosenCharacter
	end 
	
	
	ChosenCharacter.Humanoid.DisplayName = "  "
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	workspace.CurrentCamera.CameraSubject = ChosenCharacter.Humanoid
	
	ChosenCharacter.Humanoid.Died:Connect(function()
		SetSubject:FireServer()
		task.wait(2)
		ChosenCharacter:Destroy()
	end)
end)

all help would be appreciated

1 Like

A bindable event may help your issue.

You’ll need to make all of your code server-side, except GUI, use remote events.

1 Like

Like everyone said, you can use a remote event or a remote funcion.

https://developer.roblox.com/en-us/api-reference/class/RemoteEvent
https://developer.roblox.com/en-us/api-reference/class/RemoteFunction

1 Like

That’s for local script to local script or server script to server script communication.

3 Likes

Yes I know, I’m suggesting that the @OP should do the selection on the client instead of the server.