Hello! I am trying to fix a bug where the player morphs under my map and it has been really annoying, I would really like help.
Excuse my messy code, but I when the player respawns the script thinks the player is under the map and not even breakpoints can help me solve this. Code:
--- Server script ---
local function selModel(plr, morphName)
local userId = plr.UserId
if typeof(morphName)=="string" then
if repStorage:WaitForChild("PlayerModels"):FindFirstChild(morphName) then
local morph = game:GetService("ReplicatedStorage").PlayerModels[morphName]:Clone()
local pastPose = if plr.Character then if plr.Character.PrimaryPart then plr.Character.PrimaryPart.CFrame else workspace:WaitForChild("Spawn").CFrame else workspace:WaitForChild("Spawn").CFrame;
(morph.PrimaryPart or morph:FindFirstChild("HumanoidRootPart")).CFrame=pastPose
morph.Parent = workspace:FindFirstChild("Humanoids") or workspace
morph:SetAttribute("MorphName", morphName) -- breakpoint here
morph.Name = plr.Name
if plr.Character then
plr.Character:Destroy()
end
plr.Character=morph
-- blah blah blah bunch of unrelated code
end
end
end
--- Client script ---
local function projectPlr(plr)
plr.CharacterAdded:Connect(function(char)
if plr == plrs.LocalPlayer then
if not char:FindFirstChild("Morphed") then
if _G.Ready then
char:WaitForChild("HumanoidRootPart").CFrame = workspace.Spawn.CFrame
end
else
char.Morphed:Destroy()
end
end
end)
end
What’s even weirder is that it isn’t spawning the player at the world origin, also the breakpoints are showing different results: