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

how do i fix this body colours script from changing colours after the first death?

Asked by 4 years ago

i'm trying to make a game that has races similar to rogue lineage but one of the races has a green variant and when a player joins this game and gets this race/variant the body colours look perfectly fine but after they die once the shade of green changes does anybody know how to fix this

elseif player:WaitForChild("RaceVariant").Value == "Green" then
    character:WaitForChild("Body Colors").HeadColor3 = Color3.fromRGB(137, 255, 124)
    character["Body Colors"].LeftArmColor3 = Color3.fromRGB(137, 255, 124)
    character["Body Colors"].LeftLegColor3 = Color3.fromRGB(137, 255, 124)
    character["Body Colors"].RightArmColor3 = Color3.fromRGB(137, 255, 124)
    character["Body Colors"].RightLegColor3 = Color3.fromRGB(137, 255, 124)
    character["Body Colors"].TorsoColor3 = Color3.fromRGB(137, 255, 124)

2 answers

Log in to vote
0
Answered by
G2001H 75
4 years ago

Use LocalScript and put into StarterPlayerScripts

while wait() do
local player = game.Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local bodycolors = character["Body Colors"]
    if character:FindFirstChild("Humanoid") then
        bodycolors.HeadColor3 = Color3.fromRGB(137, 255, 124)
        bodycolors.LeftArmColor3 = Color3.fromRGB(137, 255, 124)
        bodycolors.LeftLegColor3 = Color3.fromRGB(137, 255, 124)
        bodycolors.RightArmColor3 = Color3.fromRGB(137, 255, 124)
        bodycolors.RightLegColor3 = Color3.fromRGB(137, 255, 124)
        bodycolors.TorsoColor3 = Color3.fromRGB(137, 255, 124)
    end
end
0
unfortunately i've already tried this and on my screen the body colours would work fine but on other players' screens my character has my roblox avatar's body colours LinkTheHero -5 — 4y
0
it's work for me G2001H 75 — 4y
Ad
Log in to vote
0
Answered by
H26O 44
4 years ago

In order to get it to load on the server (For Others to See) you must use a ServerScript place this code in a normal Script inside StarterCharacterScripts

local c = script.Parent
local bodycolors = c:WaitForChild("Body Colors")
if c:FindFirstChild("Humanoid") then
    bodycolors.HeadColor3 = Color3.fromRGB(137, 255, 124)
    bodycolors.LeftArmColor3 = Color3.fromRGB(137, 255, 124)
    bodycolors.LeftLegColor3 = Color3.fromRGB(137, 255, 124)
    bodycolors.RightArmColor3 = Color3.fromRGB(137, 255, 124)
    bodycolors.RightLegColor3 = Color3.fromRGB(137, 255, 124)
    bodycolors.TorsoColor3 = Color3.fromRGB(137, 255, 124)
end
0
if you look at the start of the script that i posted the body colours will only change if the player's race variant is green and the race is fischeran but if i add game.Players.PlayerAdded:Connect(function(player) to define player to the script you posted then it doesn't work LinkTheHero -5 — 4y
0
You don't need to get the player from PlayerAdded if the player is the parent of the script, you can just do GetPlayerFromCharacter. (The character being script.Parent) H26O 44 — 4y

Answer this question