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

How can I use DataStorage to save the players current appearance?

Asked by 2 years ago

Hello!

I want to make a script where the game will save the players appearance, and before you tell me: "But ROBLOX already have a feature where It saves your appearance". I need a script that saves the players current appearance Is because so that the morph won't go away If the player dies or leaves the game. For context:

I am working on a WoT (World of Trollge) game, WoT Is similar to those Jojo games but different. You can check the game here: https://web.roblox.com/games/8360240897/World-of-Trollge-Beta

Anyway, back to the context, I made a script Inside of a tool, what the script does Is quite simple, when the tool Is used, a simple drinking animation plays, after a few seconds It will "temporarily" morph you Into a troll (Also If your wondering why I put quotes In "Temporarily" Is because Its temporarily only If you reset or leave the game). And said earlier In the brackets, the morph will disappear when the user either dies or reset. The script for morphing can be found here:

(Oh, and also, the script for saving the players appearance can be anywhere, also I don't know how to use DataStorage)

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.Ice.Transparency = 1
        tool.Handle.Oil.Transparency = 1
        wait(1)
        local OilCupTroll = math.random(1,1)

        if OilCupTroll == 1 then
            local player = game.Players:GetPlayerFromCharacter(tool.Parent)

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

            local AveragePlayer = CharacterFolder["Reaper"]: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 = "Trollge"
        end
        if OilCupTroll == 2 then
            local player = game.Players:GetPlayerFromCharacter(tool.Parent)

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

            local AveragePlayer = CharacterFolder["HD 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 = "HD Troll"
        end
        if OilCupTroll == 3 then
            local player = game.Players:GetPlayerFromCharacter(tool.Parent)

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

            local AveragePlayer = CharacterFolder["BrickBattler"]: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 = "BrickBattler"
        end
        Debounce = false
        tool:Destroy()
    end
end)
0
How does this have 28k views? lol SharkRayMaster 265 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Please view your previous question. I have already answered. Good day!

Ad

Answer this question