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

How can I make this tool permanently gives you a morph apon usage?

Asked by 2 years ago

The title says It all

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 and tool.Parent.CanDrink.Value == true 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["Insert Morph Here"]: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 = "Insert Morph Here"
        Debounce = false
        tool:Destroy()
    end
end)

Answer this question