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

Any Help? Trying To Change Brickcolor Of A Model?

Asked by 6 years ago

Any Idea Why This Does Not Work?

LocalPlayer = game.Players.LocalPlayer Torso = game.LocalPlayer.Torso.BrickColor = ("Really red")

2 answers

Log in to vote
0
Answered by 6 years ago

A better way to write this could be in many ways:

A simple one time coloring:

local player = game:GetService("Players").LocalPlayer
player:WaitForChild("Character").Torso.BrickColor = BrickColor.new("Really red")

or a on join module:

local player = game:GetService("Players").LocalPlayer
game:GetService("Players").PlayerAdded:connect(function()
    player:WaitForChild("Character").Torso.BrickColor = BrickColor.new("Really red")

or a module to change the color when it's changed:

local player = game:GetService("Players").LocalPlayer
local wfc = game.WaitForChild
local char = wfc(player,"Character")
char:FindFirstChild("Torso").Changed:connect(function()
    if char.Torso.BrickColor == BrickColor.new("Really red") then
        --still red bro
    else
        char.Torso.BrickColor = BrickColor.new("Really red")
    end
end)
Ad
Log in to vote
0
Answered by
LeadRDRK 437 Moderation Voter
6 years ago
Edited 6 years ago

You've made a typo. You do not need game.LocalPlayer to direct it to the player since you've already made it local, AND there's no child of game named LocalPlayer. The right way to do it is just simply LocalPlayer. Here's the fixed version

local LocalPlayer = game.Players.LocalPlayer 
local Torso = LocalPlayer.Character.Torso
Torso.BrickColor = BrickColor.new("Really red")

Answer this question