You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to change the color of my leaves on my tree with a script -
What is the issue? Include screenshots / videos if possible!
I’m getting an error
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking up similar errors on google but found no solution
the module script that errors
local Leaves = {}
local LEAF_COLOR = Color3.fromRGB(0, 144, 0)
function Leaves:Init()
local Model = script.Parent
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[1].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[1].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20)
)
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[2].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[2].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20)
)
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[3].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[3].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[4].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[4].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[5].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[5].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[6].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[6].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))\
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[8].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[8].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[9].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[9].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[10].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[10].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[11].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[11].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[12].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[12].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[13].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[13].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[14].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[14].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
local Salt = math.random(-40, 40)
Model.Leaves:GetChildren()[15].Color = Color3.fromRGB(
math.clamp((LEAF_COLOR.R * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.G * 255) + Salt, 0, 255),
math.clamp((LEAF_COLOR.B * 255) + Salt, 0, 255))
Model.Leaves:GetChildren()[15].Orientation = Vector3.new(
math.random(-20, 20),
math.random(-20, 20),
math.random(-20, 20))
end
return Leaves