Hey how are you hopefully you’re good, so today I have a question. I want to know how it’s possible to use
Player:LoadCharacter()
in a local script in StarterGUI for a button I have?
I have tried a way to solve this by using Remote Events but that didn’t work for me so I’ve come here to ask how to do it any help would be appreciated thank you for your time to read this!
Hi, from what I know it is not possible to use Player:LoadCharacter() in a local script, so you can use a remote event and do it from the server.
Look I used this script in ReplicatedStorage to connect a function to the event is the script correct:
local LoadChar = game.ReplicatedStorage:WaitForChild(“LoadChar”)
local function onRemEvent_LoadChar(Player)
Player:LoadCharacter()
end
LoadChar.OnServerEvent:Connect(onRemEvent_LoadChar)
?
Yes, that is correct. The code seems to be fine.
The script should be in ServerScriptService.
Thats the code in my button is it correct?
local Player = script.Parent.Parent.Parent
local Button = script.Parent.Frame.GloveDeku
local Characters = game.ReplicatedStorage.Characters
local LoadChar = game.ReplicatedStorage.LoadChar
Button.MouseButton1Down:Connect(function()
wait()
script.Parent.Enabled = false
game.ReplicatedStorage.Characters.GloveDeku.Name = "StarterCharacter"
game.ReplicatedStorage.Characters.StarterCharacter.Parent = game.StarterPlayer
LoadChar:FireServer()
end)
Wait really I thought it was supposed to be in replicated storage
the remoteevent goes in the replicatedstorage but the script goes in ServerScriptService
also when doing code use ``` before and after
Oh i see thanks man so ill put the script in server script service and ill see if it works
Ok but your forgot to connect the function and remote event in the server server script service
They did not.
event.OnServerEvent:Connect(function(plr)
end)
works as well as
local function func(plr)
end
event.OnServerEvent:Connect(func)
But it didnt really work since I have a character selection ui and I want it to go not visible when the button is pressed and I want it to load a new character but that restarts the program and then the ui will be visible again how do i fix that
Let me get this straight, so when you do Player:LoadCharacter it made the UIs reset?
I think set ResetOnSpawn = false
yes everything resets ui and like the whole game so idk how to fix that with a variable?
Set it to false
or maybe in the Player:LoadCharacter() do that
Remote_Event.OnServerEvent:Connect(function(Player)
wai(1)
Player:LoadCharacter()
end)
In what object is that property?
Screen Gui
Ok now that thats fixed theres one more problem its that the actual avatar of the character is overriding the StarterChracter
Show me, I don’t get it so it better if you record a screen recoding