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

I need some help to fix my morph system, It works however there are a few Issues (?)

Asked by 2 years ago

Hello!

With the help with @LikeableEmmec and someone else (I'll get their name later), I've made a morph system for my WoT game, If you use a tool (Which the tools are called "Cups") you will be morph Into a troll, but not only that, but the morph will also not go away. Meaning If you die/reset or leave the game, you will still have the morph, the problem however Is:

  1. You will be teleported to where the morph Is If you reset or leave with the morph on (This doesn't affect players who manage to get the morph)
  2. I want It so that the morph system will give you different morphs each time you use It, for example, there are 3 morphs you can get on the tool, you can get one of them by an RNG type system

I also heard there was a bug where the camera gets glitched, but I don't think so

Oh and also, there Is a custom player when you spawn, so If you join my game, your avatar will be turned Into a troll

Tool script (Server-side, Inside of tool):

local tool = script.Parent
local Debounce = false
local DrinkingAnimation = tool.Animation or tool:WaitForChild("Animation")
local Rep = game.ReplicatedStorage
local CharacterFolder = Rep.ExclusiveTrolls
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(0.50)
        tool.Handle.Oil.Transparency = 1
        tool.Handle.Oil.Attachment.ParticleEmitter.Enabled = false
        wait(1)
        local player = game.Players:GetPlayerFromCharacter(tool.Parent)
        player.CurrentMorph.Value = "Reaper"

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

        local AveragePlayer = CharacterFolder["Über S ?cret TrÖll"]:Clone()
        AveragePlayer.Name = player.Name
        AveragePlayer.Parent = workspace

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

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

        player.Character = AveragePlayer

        AveragePlayer.Humanoid.DisplayName = "Über S ?cret TrÖll"
        Debounce = false
        tool:Destroy()
    end
end)

Script (Inside of ServerScriptService, server-side):

local CharacterFolder = game.ReplicatedStorage.ExclusiveTrolls
local store = game:GetService("DataStoreService")
local store2 = store:GetDataStore("Morph")

function save(p,val)
    store2:SetAsync(p.UserId,val)
end

game.Players.PlayerAdded:Connect(function(p)
    local val = store2:GetAsync(p.UserId) or ""

    local stringv = Instance.new("StringValue",p)
    stringv.Name = "CurrentMorph"
    stringv.Value = val
    p.CharacterAdded:Connect(function(c)
        if stringv.Value ~= "" then
            local oldchar = c
            local oldv = stringv.Value
            stringv.Value = ""
            local plrRoot = p.Character:WaitForChild("HumanoidRootPart") or p.Character.Parent:WaitForChild("Torso")

            local AveragePlayer = CharacterFolder["Über S ?cret TrÖll"]:Clone()
            AveragePlayer.Name = p.Name

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

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

            p.Character = AveragePlayer

            AveragePlayer.Parent = workspace
            AveragePlayer.Humanoid.DisplayName = "Über S ?cret TrÖll"
            oldchar:Destroy()
            stringv.Value = oldv
        end
    end)
end)

game.Players.PlayerRemoving:Connect(function(p)
    local stringv = p:WaitForChild("CurrentMorph")
    save(p,stringv.Value)
end)

Answer this question