So I’ve been having trouble with my character selection gui, it works ok like it changes your character but your camera also becomes really messed up these are my scripts:
Local Script: local gui = script.Parent
local player = game.Players.LocalPlayer
gui.MouseButton1Click:Connect(function()
gui.RemoteEvent:FireServer()
end)
ServerScript: local gui = script.Parent
gui.RemoteEvent.OnServerEvent:Connect(function(player)
local char = player.Character
local change = game.ServerStorage.CharacterDummy:Clone()
change.Parent = workspace
player.Character = change
change.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
end)
so yeah if anyone could tell me what went wrong it would be incredibly appreciated and yeah have a great day!
I’ve reformatted your original response to be readable, incase others might have a hard time reading this.
Local Script:
local gui = script.Parent
local player = game.Players.LocalPlayer
gui.MouseButton1Click:Connect(function()
gui.RemoteEvent:FireServer()
end)
Server Script:
gui.RemoteEvent.OnServerEvent:Connect(function(player)
local char = player.Character
local change = game.ServerStorage.CharacterDummy:Clone()
change.Parent = workspace
player.Character = change
change.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
end)
From what I see, this isn’t an issue with your code, although I would try to make a few changes to how the new character is spawned.
My ‘fix’:
gui.RemoteEvent.OnServerEvent:Connect(function(player)
local char = player.Character
local change = game.ServerStorage.CharacterDummy:Clone()
change:SetPrimaryPartCFrame(char:GetPrimaryPartCFrame())
change.Parent = workspace
player.Character = change
char:Destroy()
end)
This may cause issues, so I would try to experiment. This may also be an issue with Roblox’s CameraModule, so try experimenting with CurrentCamera.CameraSubject.
It worked the same way as it did before I’ll show you a video but I also got in the output something called “Infinite Yield Possible” but anyways here’s the video