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

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

Asked by 2 years ago

Hello! I am making a World of Trollge game. So with the help of someone, we made this script, what this script does Is that when you drink It (or activate It) It will transform you Into a morph (Note: This script Is a test script, the real script Is the same, just with RNG added with It).

The goal here however Is to make the morph permanent, because when you die, your morph will be removed (Also, all morphs have tools (with usually has no handles Inside of It) or abilities)

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