So i made my custom gui morph, when player clicks it the player will morph to that model. Anyway, my problem is when the player dies the morph also is gone.. is there anyway i can make it persistence? so even the player dies it will still be there.. Because i think this can make my game i'm currently developing to be decent. My friend he helps me but he don't also know how. I also tried learning the idea of data/inventory persistence but it didn't go well.
In order for this to work morph the model you want to turn into and then place them into the Morphs Folder in the MorphGui
local Player = script.Parent.Parent.Parent local Me = Player.Character or Player.CharacterAdded:wait() local Morphs = script.Parent.Morphs:GetChildren() function Morph(Suit) if Me:findFirstChild("Chest") == nil then for i,v in pairs(Me:GetChildren()) do if v.ClassName == "Part" then v.Transparency = 1 end end if Me.Head:findFirstChild("face") ~= nil then Me.Head.face:Destroy() end if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Arm1") == nil and Suit:findFirstChild("Arm1") ~= nil then local g = Suit.Arm1:clone() g.Parent = Me local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = Me["Left Arm"] Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then h[i].Anchored = false h[i].CanCollide = false end end end if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Arm2") == nil and Suit:findFirstChild("Arm2") ~= nil then local g = Suit.Arm2:clone() g.Parent = Me local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = Me["Right Arm"] Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then h[i].Anchored = false h[i].CanCollide = false end end end if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Leg1") == nil and Suit:findFirstChild("Leg1") ~= nil then local g = Suit.Leg1:clone() g.Parent = Me local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = Me["Left Leg"] Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then h[i].Anchored = false h[i].CanCollide = false end end end if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Leg2") == nil and Suit:findFirstChild("Leg2") ~= nil then local g = Suit.Leg2:clone() g.Parent = Me local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = Me["Right Leg"] Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then h[i].Anchored = false h[i].CanCollide = false end end end if Me:findFirstChild("Humanoid") ~= nil and Me:findFirstChild("Chest") == nil and Suit:findFirstChild("Chest") ~= nil then local g = Suit.Chest:clone() g.Parent = Me local C = g:GetChildren() local R = Me:GetChildren() for i=1, #R do if R[i].className == "Hat" then R[i]:Destroy() end end for i=1, #C do if C[i].className == "Part" or C[i].className == "WedgePart" or C[i].className == "CornerWedgePart" or C[i].className == "UnionOperation" then local W = Instance.new("Weld") W.Part0 = g.Middle W.Part1 = C[i] local CJ = CFrame.new(g.Middle.Position) local C0 = g.Middle.CFrame:inverse()*CJ local C1 = C[i].CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = Me.Torso Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do if h[i].className == "Part" or h[i].className == "WedgePart" or h[i].className == "CornerWedgePart" or h[i].className == "UnionOperation" then h[i].Anchored = false h[i].CanCollide = false end end end else Me.Arm1:Destroy() Me.Arm2:Destroy() Me.Chest:Destroy() Me.Leg1:Destroy() Me.Leg2:Destroy() Morph(Suit) end end local enabled = true local y = 0 for i,v in pairs(Morphs) do local Button = script.TextButton:Clone() Button.Position = UDim2.new(0,0,y*0.1,0) y = y + 1 Button.Name = v.Name Button.Text = v.Name Button.Parent = script.Parent.Background.Box Button.MouseButton1Down:connect(function() if not enabled then return end enabled = false Morph(v) enabled = true end) end
I would probably just make an event for when the character respawns when they die they get the morph a few seconds after they spawn, and use that in combination with the DataStoreService to make it stay when the player leaves the game.