Here’s the context:
I am trying to generate cart ride track infinently forward by 30 studs
The problem is my code properly copies the track forward by 30 studs and repeats that in the same place
Here’s what i have so far:
while wait(0.5) do
local ride = workspace:WaitForChild("Ride")
local newRide = ride:Clone()
newRide.Parent = game.Workspace
newRide.Position = newRide.Position + Vector3.new(30,0,0)
end
use wait() only not wait(0.5) (30 LIMITS AAAAAAAAAAAAAAAAA)
Try this: (:
local numberOfTracks = 10
local ride = workspace:WaitForChild("Ride")
for i = 0, numberOfTracks do
local newRide = ride:Clone()
newRide.Parent = workspace
newRide.Position = newRide.Position + Vector3.new(i * 30,0,0)
end
end
You are cloning it in the exact same spot every time, and aren’t defining a new value to set the position to each time. It will always be whatever newRide.Position is + 30 because you are never increasing it.
Hope this helped.
local ride = workspace:WaitForChild("Ride")
while wait(0.5) do
local newRide = ride:Clone()
newRide.Parent = game.Workspace
newRide.Position = newRide.Position + Vector3.new(30,0,0)
ride = newRide
end
You can store the latest position of the newest ride and add on from that. Also, using while wait() do is bad practice.
local ride = game.Workspace.Ride;
local lastPos = ride.Position;
while true do
wait(.5);
local newRide = ride:Clone();
newRide.Parent = game.Workspace;
newRide.Position = lastPos + Vector3.new(30, 0, 0);
lastPos = newRide.Position;
end