This script is placed inside a brick, and players are assigned a colour which is in a folder I called Settings, which is placed in the Player, and there's a Brickcolor Value and when this brick is touched, I want the Brick's colour to be the BrickColor Value that the player was assigned, but for some reason this is not working, yet no output.
function onTouched(hit) local check = hit.Parent:FindFirstChild("Humanoid") if check ~= nil then local name = hit.Parent.Name local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:FindFirstChild("Settings").Colour if stats ~= nil then script.Parent.BrickColor = BrickColor.new(stats.Value) end end end script.Parent.Touched:connect(onTouched)
Assuming stats is a BrickColorValue and not a string value, you can't make a brickcolor out of a brick color? What you're doing is:
BrickColor.new(BrickColor.Green()) --trying to create brickcolor with another brickcolor
You can't do that so just use stats.Value as the brickcolor
function onTouched(hit) local check = hit.Parent:FindFirstChild("Humanoid") if check then -- ~= nil isn't needed local name = hit.Parent.Name local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:FindFirstChild("Settings").Colour if stats ~= nil then script.Parent.BrickColor = stats.Value end end end script.Parent.Touched:connect(onTouched)
script.Parent.Touched:connect(function(Touched) if Touched.Parent ~= nil and Touched.Parent:FindFirstChild("Humanoid") ~= nil then local User = game.Players:FindFirstChild(Touched.Parent.Name); local Stats = User:WaitForChild("Settings"):FindFirstChild("Colour"); if Stats ~= nil then script.Parent.BrickColor = BrickColor.new(Stats.Value); end end end)
This is assuming that you're using a StringValue. I know that Yellow just answered it using a BrickColorValue but this will be relevant to anyone who is using a StringValue with the same problem.