Snow tree script not working?

So I have this small script that should turn trees white does not work, any help??

game.Players.PlayerAdded:connect(function(newplayer)

if script.SnowTree.Value == true then

for _,v in pairs(game.Workspace.Trees:GetChildren()) do

v.Leaves.BrickColor = BrickColor.White()

end

end

end)

image

1 Like

The code should look like this:

game.Players.PlayerAdded:Connect(function(newplayer)

if script.SnowTree.Value == true then

for _,v in pairs(game.Workspace.Trees:GetChildren()) do
    v.Leaves.BrickColor = BrickColor.new("White")
 end

  end
end)

Its not working though. Any help??

I think because it’s a script it works only on server side.

It is server sided though???

Is SnowTree value set as false in default? And are you changing it to true on client?

If the leaves are unions, make sure to set their UsePartColor property to true.

1 Like

No, its already true, its just a bool value.

Oh because it as mesh part you should use Color so the script should be:

game.Players.PlayerAdded:Connect(function(newplayer)

if script.SnowTree.Value == true then

for _,v in pairs(game.Workspace.Trees:GetChildren()) do
    v.Leaves.Color = Color3.fromRGB(1,1,1)
 end

  end
end)

Fixed it.

game.Players.PlayerAdded:Connect(function(newplayer)
if script.SnowTree.Value == true then
for _,v in pairs(game.Workspace.Trees:GetChildren()) do
	 v.Leaves.Color = Color3.fromRGB(1,1,1)
    v.Leaves.TextureID = "rbxassetid://132155326"
 end

  end
end)
2 Likes

Just curious, is there a reason why you want to run this code whenever a player joins?
If this is client-sided, PlayerAdded wont trigger. Make sure SnowTree is true and Leaves.UsePartColor is true if it’s a union.

No its server sided, the reason I trigger it when the player joins is I needed a function to be able to use a end) because I use 1 big main script for all of my script, saves space.

So you trigger an anonymous function whenever a player joins just for the sake of readability?

do
	-- function
end

Also, you are able to change a MeshPart’s BrickColor property, don’t be confused about that.

1 Like

Mark it as a solution, please.