I made a developer product, and if you buy it, you morph into a character. But if you die the error pops up and you will spawn in the air and fall down and die. How do I fix this bug?
Here’s the script:
game.MarketplaceService.PromptProductPurchaseFinished:Connect(function(plrs, id, result)
if id == 1681235708 then
if result == true then
local plr = game.Players:GetPlayerByUserId(plrs)
local oldCharacter = plr.Character
local morphModel = game:GetService(“ReplicatedStorage”).RainbowPomni:FindFirstChild(“RainbowPomni”)
local newCharacter = morphModel:Clone()
newCharacter.PrimaryPart.Anchored = false
newCharacter.Name = plr.Name
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
oldCharacter:Destroy()
plr.Character = newCharacter
newCharacter.Parent = workspace
morphModel = nil
newCharacter = nil
wait(3)
local x = Instance.new("StringValue", plr)
x.Name = "Pomni"
end
end
end)
Thanks for your help!
set the player’s character archivable property to true then set it to false after so:
game.MarketplaceService.PromptProductPurchaseFinished:Connect(function(plrs, id, result)
if id == 1681235708 then
if result == true then
local plr = game.Players:GetPlayerByUserId(plrs)
local oldCharacter = plr.Character
local morphModel = game:GetService(“ReplicatedStorage”).RainbowPomni:FindFirstChild(“RainbowPomni”)
morphModel.Archivable = true
local newCharacter = morphModel:Clone()
newCharacter.PrimaryPart.Anchored = false
newCharacter.Name = plr.Name
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
morphModel.Archivable = false
oldCharacter:Destroy()
plr.Character = newCharacter
newCharacter.Parent = workspace
morphModel = nil
newCharacter = nil
wait(3)
local x = Instance.new("StringValue", plr)
x.Name = "Pomni"
end
end
end)
Thanks for your reply. I’m sorry to say it still doesnt work, even if the character is archivable
You need to put your character in StarterCharacterScripts first of all, and add important parts in a character like HumanoidRootPart etc.
Now after the character bought the morph, reset the character and it should work fine. I know it won’t be a “clean” transition between morph but it will work.
The benefit of putting it in StarterCharacterScripts would be that it’s basically the starter character, which means everytime you reset your character, the model will spawn.