Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script that should morph the character makes it respawn after morphing, why?

Asked by 5 years ago
Edited 5 years ago

...Literally, what the title says.

Basically, the script does what it was inteded to, morph the character, set it's camera to the primary part, everything good!.

The problem is... 5 seconds after morphing, the character respawns like a normal character, basically, the game thinks the player died.

The script is uh... this:

local morph = game.ReplicatedStorage.Puro
local pad = script.Parent

pad.Touched:connect(function(hit)
    local par = hit.Parent
    if par.ClassName == "Model" then
    local morphd = par:FindFirstChildWhichIsA("BoolValue")
    if morphd.value == false then
        local hum = par:FindFirstChild("Humanoid")
        if hum then
            local ply = game.Players:GetPlayerFromCharacter(par)
            if ply then
                local morphClone = morph:Clone()
                morphClone.Name = par.Name
                morphClone.Parent = game.Workspace
                morphClone.PrimaryPart.CFrame = par.PrimaryPart.CFrame
                ply.Character = morphClone
                par:Destroy()
                wait(0.5)
                local Animator = morphClone:FindFirstChild("Animator")
                Animator.Disabled = false
                local Dyez = morphClone:FindFirstChild("CommitDyez")
                Dyez.Disabled = false
                game.Workspace.EVENTS["AnimationChange (Puro)"]:FireClient(hit)
            end
            end
        end
    end
end)

STUFF IN DETAIL:

The script "animator" is a edited version of the animator script made to have the custom character's animations.

"CommitDyez" is a LocalScript to set the character's camera to the primarypart

the "event:fireclient" is used for giving a clientEvent to the player's GUI, showing the GUI with animations for the character.

My Hypothesis is that on the line "par:Destroy()" is when the character is named "dead" by the game, forcing him to respawn.

If there is a way to cancel the respawn, tell me, I'd really be happy of that.

0
Why are you calling "par:Destroy()"? That's basically just destroying the player, making him/her respawn. Pojoto 329 — 5y
0
How do i get rid of the starter player chararacter, then?, Else it'll be just tposing as a ragdoll on the floor. Chris75764 49 — 5y
0
Yeah, don't reply back, thanks for the "EXTREMELY USEFULL" info. Chris75764 49 — 5y

Answer this question