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

How can I make sure the tool Is removed as well of the tool morphing the player (?)

Asked by 2 years ago

Hello!

I made a morph tool that morphs you Into a character with attacks, It works just I want the tool to destroy Itself when the player Is done morphing which does not, also when morphing there Is a glitch where all Its attacks (Which are tools btw (Also there Inside of the morph)) are equip together and won't let you select other attacks unless If you unequip one of those attacks

Script:

local tool = script.Parent
local Debounce = false
local DrinkingAnimation = tool.Animation or tool:WaitForChild("Animation")
local Rep = game.ReplicatedStorage
local CharacterFolder = Rep.Morphs
local char = tool.Parent

tool.Activated:Connect(function()
    if not Debounce then
        Debounce = true
        tool:WaitForChild("Drink"):Play()
        local AnimationTrack = tool.Parent.Humanoid:FindFirstChild("Animator"):LoadAnimation(DrinkingAnimation)
        AnimationTrack:Play()
        wait(1)
        local player = game.Players:GetPlayerFromCharacter(tool.Parent)

        local plrRoot = player.Character:FindFirstChild("HumanoidRootPart") or player.Character.Parent:FindFirstChild("Torso")

        local AveragePlayer = CharacterFolder["Soda Troll"]:Clone()
        AveragePlayer.Name = player.Name
        player.Character = AveragePlayer

        local rootPart = AveragePlayer:FindFirstChild("HumanoidRootPart") or AveragePlayer:FindFirstChild("Torso")

        if rootPart and plrRoot then
            rootPart.CFrame = plrRoot.CFrame
        end

        AveragePlayer.Parent = workspace
        AveragePlayer.Humanoid.DisplayName = "Soda Troll"
        Debounce = false
        tool:Destroy()
    end
end)

Answer this question