Hi, I am working on a game and I am trying to change a Player’s Character Mid-Game (kinda like piggy)
and I have done it, but there is something strange going on with the camera of the player so when I change the player’s character the camera stays at the old character’s position.
Here is my code that changes the player’s character:
local Players = game:GetService("Players")
local status = game:GetService("ReplicatedStorage").Information
local mummychar = game.ServerStorage.Mummy:Clone()
while true do
local Countdown = 15 -- intermission, make this as long as you want
repeat wait(1)
Countdown = Countdown - 1
status.Value = 'Intermission : '..Countdown
until Countdown <= 0
local mummy = Players:GetChildren()[math.random(1, #Players:GetChildren())]
status.Value = mummy.Name.." Is The Mummy!"
wait(5)
mummychar.Parent = workspace
mummy.Character.Humanoid.Health = 0
mummy.Character.Humanoid.Died:Connect(function()
mummy.Character = mummychar
end)
end
I believe this is not the correct way to change a player’s character.
You should do this:
local Players = game:GetService("Players")
local status = game:GetService("ReplicatedStorage").Information
while true do
local Countdown = 15 -- intermission, make this as long as you want
repeat wait(1)
Countdown = Countdown - 1
status.Value = 'Intermission : '..Countdown
until Countdown <= 0
local mummy = Players:GetChildren()[math.random(1, #Players:GetChildren())]
status.Value = mummy.Name.." Is The Mummy!"
wait(5)
local newMummy = game.ServerStorage.Mummy:Clone()
newMummy.Parent = game.Workspace
newMummy.Name = mummy.Name
mummy.Character = newMummy
end