I want to make it so that every know and then there will be cacti, lamp poles, etc. generated with a random set of numbers. I have a base script already that just generates road but nothing fancy
The issue is that I am having trouble figuring out how to solve my problem
This is the script I have so far feel free to ask any questions
local visited = {}
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
while char.Humanoid.Health > 0 do
wait()
for i = -2,2 do
local zPos = math.floor((char.HumanoidRootPart.Position.Z + i * 100) / 100 + 0.5) * 100 --rounded
if visited[zPos] == nil then
visited[zPos] = script.Road:Clone()
local p = visited[zPos]
p:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,2,zPos)))
p.Parent = workspace.Road
end
end
end
end)
end)