Didn’t need to add a wait, Thanks. But I encountered a new problem when a player sends a remote to server and the client changes his camera cframe while this delay is happening how do I sync it
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,cf)
local c = char:Clone()
local Root = player.Character.HumanoidRootPart
c:PivotTo(Root.CFrame)
player.Character = c
c.Parent = workspace
print("WEWEWEW") -- prints
game.ReplicatedStorage.RemoteEvent:FireClient(player,cf)
end)
but some why fire client doesn’t run and no fire client reached and if I remove player.Character = c it runs good
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(cf)
print("Rec")
workspace.CurrentCamera.CFrame = cf
end)
game:GetService("UserInputService").InputBegan:Connect(function(e)
if e.KeyCode == Enum.KeyCode.E then
game.ReplicatedStorage.RemoteEvent:FireServer(workspace.CurrentCamera.CFrame)
end
end)
btw I do this because if I set Player.Character to something inside of the remote event in the server the client changes the camera subject thus adjusting beforeI fire a remote event is wrong
game:GetService("UserInputService").InputBegan:Connect(function(e)
if e.KeyCode == Enum.KeyCode.E then
local prev_cframe = workspace.CurrentCamera.CFrame
game.ReplicatedStorage.RemoteEvent:FireServer()
task.wait() -- Might not be needed
workspace.CurrentCamera.CFrame = prev_cframe
end
end)
Server code:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
local Root = player.Character.HumanoidRootPart
local c = char:Clone()
c:PivotTo(Root.CFrame)
c.Parent = workspace
player.Character = c
end)