I'm trying to make it so two different types of grass spawn at different times of day.
local grassTime = game.Lighting:GetMinutesAfterMidnight()
local sunGrass = game.ServerStorage.SunGrass
local moonGrass = game.ServerStorage.MoonGrass
local function spawnSunGrass()
local sunCopy = sunGrass:Clone()
sunCopy.Parent = game.Workspace.SunGrass
local xPos = math.random(-3500, 3500)/100
local zPos = math.random(-3500, 3500)/100
sunCopy.Position = Vector3.new(xPos, 1, zPos)
end
local function spawnMoonGrass()
local moonCopy = moonGrass:Clone()
moonCopy.Parent = game.Workspace.MoonGrass
local xPos = math.random(-3500, 3500)/100
local zPos = math.random(-3500, 3500)/100
moonCopy.Position = Vector3.new(xPos, 1, zPos)
end
--Problems start here.
while true do
grassMath = math.random(1, 50)
if grassMath == 1 and grassTime >= 480 and grassTime <= 1320 then
spawnSunGrass()
wait()
end
if grassMath == 2 and grassTime <= 480 and grassTime >= 1320 then
spawnMoonGrass()
wait()
end
end
I've tried doing an if statement for each thing, one for grassMath and two for grassTime. I get all sorts of different results by changing bits and pieces, and have no clue where it's going wrong.

1 comment
I am not sure if this will work but have you tried elseif instead of 2 separate if statements?