Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to load the character in a local script?

I've tried using a remote event but I don't think my script is right

local script in the playergui:

local pos = CFrame.new(4.179, 6.653, 73.886)
local player = game.Players.LocalPlayer
local resetBindable = Instance.new("BindableEvent")
local remote = game.ReplicatedStorage.BigRemote

resetBindable.Event:Connect(function() -- put code under event
    remote:FireServer(player)
    player.Character:SetPrimaryPartCFrame(pos)
    
end)

game:GetService("StarterGui"):SetCore("ResetButtonCallback", resetBindable)

regular server script in script service:

local remote = game.ReplicatedStorage.BigRemote

remote.OnServerEvent:Connect(function(player)
	player:LoadCharacter()
end)

2 comments

0

Don't pass the player as an argument on FireServer

0

I posted a video on this a bit ago. https://www.youtube.com/watch?v=xHbvyX456Jw

1 answer

Localscript:

local pos = CFrame.new(4.179, 6.653, 73.886)
local player = game.Players.LocalPlayer
local resetBindable = Instance.new("BindableEvent")
local remote = game.ReplicatedStorage.BigRemote

resetBindable.Event:Connect(function() -- put code under event
    remote:FireServer()
    player.Character:SetPrimaryPartCFrame(pos)

end)

game:GetService("StarterGui"):SetCore("ResetButtonCallback", resetBindable)

If you don't need the player anymore, just remove it. Here's the server sided.

local remote = game.ReplicatedStorage.BigRemote

remote.OnServerEvent:Connect(function(player)
    player:LoadCharacter()
end)

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