In this scenario, I want to :LoadCharacter locally. I know that this can only be fired from a server script. How would I go about doing so with a Remote Event?
3 Likes
I’m not sure why you would want to load the character through the client, but here is the wiki for remote events / functions https://developer.roblox.com/articles/Remote-Functions-and-Events.
anyways, here is a simple script for what you are looking for:
--// Server
local replicatedstorage = game:GetService("ReplicatedStorage");
local event = Instance.new("RemoteEvent", replicatedstorage);
event.Name = "LoadCharacter";
event.OnServerEvent:connect(function(player)
player:LoadCharacter();
end)
and this can be fired by:
--// Client
local replicatedstorage = game:GetService("ReplicatedStorage");
local event = replicatedstorage:WaitForChild("LoadCharacter");
--// firing the event
event:FireServer();
now remember the client can fire this anytime.
I recommend checking the remote event wiki for more information on doing remote events.
3 Likes
Thanks, this was really helpful. I’m doing this locally because it’s a MouseButton1Click event that will trigger the code locally.
1 Like