I’m very new to learning code, and I’m just learning the basics. However, I have problems with the code and the output in the game.
So basically, I tried to make a tree, but I made a horrendous mess, there are some pictures below that show the tree in studio and the tree from the output:
Studio tree
local trunk = workspace.treeTrunk
local top = workspace.topOfTheTree
local foliage = workspace.biggestTreeFoliagePart -- this part is a model so maybe this helps?
trunk.BrickColor = BrickColor.new(20, 20, 3)
top.BrickColor = BrickColor.new(3, 20, 3)
foliage.BrickColor = BrickColor.new(3, 20, 3)
trunk.Anchored = true
top.Anchored = true
foliage.Anchored = true
If you have anymore question regarding this ask. Thanks for reading this!
Put it suspended in the air. If it falls down something isn’t anchored.
I don’t think brickcolor.new is used for color3.new options.
If you want brickcolors you use strings, like “cocoa”, not numbers for the part colors. If you use Color3 you use a Color3, a number, which could be, for example, 20, 20, 3. Then again, I don’t know if this is what you planned, I just think it’s not what you want.
It still isn’t working, its collapsing to the ground in multiple different colourless (I’m British) parts. Should I just entirely scrap the model and make things to replace the void of the foliage?
Try implementing another check using GetDescendants maybe?
local trunk = workspace.treeTrunk
local top = workspace.topOfTheTree
local foliage = workspace.biggestTreeFoliagePart -- this part is a model so maybe this helps?
trunk.BrickColor = BrickColor.new(20, 20, 3)
top.BrickColor = BrickColor.new(3, 20, 3)
foliage.BrickColor = BrickColor.new(3, 20, 3)
trunk.Anchored = true
top.Anchored = true
for _, Part in pairs(foliage:GetDescendants()) do
if Part:IsA("BasePart") then
Part.Anchored = true
end
end
You should also check your Output for any potential errors you could come across
You don’t even need to use scripts for this. Just go in the model and make all the color for the parts what you want and also anchor them all. It is quite simple.
If the model foliage has parts in it then I recommend using a in pairs loop
So you can modify all the parts inside the foliage model.
local foliage = workspace.biggestTreeFoliagePart:GetChildren()
for i,v in pairs do
v.Anchored = true
v.BrickColor = Color3.fromRGB(3, 20, 3)
print(i.."has been modified")
end
If it’s one part inside a model then use this script.
MAKE SURE TO PUT THE PART INSIDE OF biggestTreeFoliagePart IN THE WORKSPACE!
--Variables
local trunk = workspace.treeTrunk
local top = workspace.topOfTheTree
local foliage = workspace.part -- replace 'part' with whatever that was part inside of the 'biggestTreeFoliagePart' model.
--Script
trunk.BrickColor = Color3.fromRGB(20, 20, 3)
top.BrickColor = Color3.fromRGB(3, 20, 3)
foliage.BrickColor = Color3.fromRGB(3, 20, 3)
trunk.Anchored = true
top.Anchored = true
foliage.Anchored = true
Tell me if I got something wrong in the script, or if I misunderstood the “foliage”.
If you get any errors from the new script please make sure to send photos or just copy & paste them in your post.