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

How would I constantly give the character a stringvalue?

Asked by 3 years ago
Edited 3 years ago

At the moment I have a script that gives a player a stringvalue called "CurrentRace" (which decides their race). But at the moment if they die with the current race stringvalue they lose their race, how would I make it so the currentrace automatically replicates into the new character?

-- ev 3/2/2021
Players.PlayerAdded:Connect(function(player)
    repeat
        wait()
    until
    player.Character

    local chosenRace = races[math.random(1,#races)]
    player.Character:WaitForChild("CurrentRace").Value = chosenRace
    if chosenRace == "Forturs" then
        local roll2 = math.random(1,2)
        if roll2 == 1 then
        local colour = Color3.fromRGB(170, 0, 0) -- fill this RGB value in
        local bodyColours = player.Character:WaitForChild("Body Colors")
        bodyColours.HeadColor3 = colour
        bodyColours.LeftArmColor3 = colour
        bodyColours.RightArmColor3 = colour
        bodyColours.LeftLegColor3 = colour
        bodyColours.RightLegColor3 = colour
        bodyColours.TorsoColor3 = colour
        end
        if roll2 == 2 then
            local colour = Color3.fromRGB(0, 170, 0) -- fill this RGB value in
            local bodyColours = player.Character:WaitForChild("Body Colors")
            bodyColours.HeadColor3 = colour
            bodyColours.LeftArmColor3 = colour
            bodyColours.RightArmColor3 = colour
            bodyColours.LeftLegColor3 = colour
            bodyColours.RightLegColor3 = colour
            bodyColours.TorsoColor3 = colour
        end
    else
        if chosenRace == "Hahns" then
            local colour = Color3.fromRGB(0, 85, 255) -- fill this RGB value in
            local bodyColours = player.Character:WaitForChild("Body Colors")
            bodyColours.HeadColor3 = colour
            bodyColours.LeftArmColor3 = colour
            bodyColours.RightArmColor3 = colour
            bodyColours.LeftLegColor3 = colour
            bodyColours.RightLegColor3 = colour
            bodyColours.TorsoColor3 = colour
            local clone = game.ServerStorage.Barbarity
            clone.Parent = player.Character
        else
            if chosenRace == "Yitals" then
                local colour = Color3.fromRGB(248, 255, 201) -- fill this RGB value in
                local bodyColours = player.Character:WaitForChild("Body Colors")
                bodyColours.HeadColor3 = colour
                bodyColours.LeftArmColor3 = colour
                bodyColours.RightArmColor3 = colour
                bodyColours.LeftLegColor3 = colour
                bodyColours.RightLegColor3 = colour
                bodyColours.TorsoColor3 = colour
            else
                if chosenRace == "Pardeos" then
                    local colour = Color3.fromRGB(255, 255, 255) -- fill this RGB value in
                    local bodyColours = player.Character:WaitForChild("Body Colors")
                    bodyColours.HeadColor3 = colour
                    bodyColours.LeftArmColor3 = colour
                    bodyColours.RightArmColor3 = colour
                    bodyColours.LeftLegColor3 = colour
                    bodyColours.RightLegColor3 = colour
                    bodyColours.TorsoColor3 = colour
                end
            end
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

First, you haven't :Clone()'d the "clone" variable, also, you could just place the StringValue inside of StarterCharacter, as everything under StarterCharacter gets automatically placed inside of a players character.

0
It works, thanks for the improvement! But now the race resets upon dying, (CurrentRace still clones but it resets the race back to Raceless) kegirosou 17 — 3y
0
I updated the post with the rolling script. it's very messy but where would i be able to make it so based on their chosenrace it would stay even if they died? kegirosou 17 — 3y
0
You could also just parent it under player, which would require PlayerAdded. Anytime they reset it won't go away AmokahTheFox 30 — 3y
0
It works, but the skin tone is removed, how would I keep the skin tone when it resets (your suggestion did work so I'll accept the answer) but this is just a secondary question. kegirosou 17 — 3y
View all comments (2 more)
0
You can always save it to a table, too AmokahTheFox 30 — 3y
0
What do you mean by that? Do you mean store the RGB colors into a table, if so how would I do that and how would it save it upon the character dying? kegirosou 17 — 3y
Ad

Answer this question