So I am trying to make an Transformation Script work so when you click a button it will change you character from the current one to the one selected , but I can’t seem to make it work so when you die it saves the new character
Problem: When player dies the character reverts to original?
Code:
local model,oldModel,newModel,oldCFrame,player,modellname
function respawnPlayer(plr, modelName)
player = plr
modellname = modelName
model = game.ReplicatedStorage.Skins:FindFirstChild(modelName)
print("Model from server is", model)
oldModel = plr.Character
newModel = model:Clone()
oldCFrame = oldModel:GetPrimaryPartCFrame()
plr.Character = newModel
newModel.Parent = workspace
newModel:SetPrimaryPartCFrame(oldCFrame)
oldModel:Destroy()
end
game.ReplicatedStorage.Skins.ChangeCharacter.OnServerEvent:Connect(respawnPlayer)
How do I make it so when the player dies and respawns he has the same character that he selected?