Hey all ! I wanted to try make a little project for fun, but I didnt know where to start with this part here, I want to have randomly selected parts that I’d make and for them to appear in a line and move along in a chain, then delete when they move past a certain point.
I don’t want a full script given to me, I just want to know where to start/best way of achieving this ? thank you for any help !
1 Like
I’ve got what I invisioned working, but there’s these gaps between the parts because of how I’ve spawned them, can anyone help ? I’ve attached the script for moving and spawning the parts
Moving:
local part = script.Parent
local target = game.Workspace.Target
while true do
local dt = task.wait()
local distance = (target.Position - part.Position).Magnitude
local speed = game.Workspace.Speed.Value*dt
local estimatedTime = speed /distance
local adjustedLerpAlpha = math.min(estimatedTime,1)
part.CFrame = part.CFrame:Lerp(target.CFrame,adjustedLerpAlpha)
end
Spawner:
local RS = game:GetService("ReplicatedStorage")
local worldParts = RS:WaitForChild("WorldParts"):GetChildren()
while true do
local parts = game.Workspace:GetPartsInPart(script.Parent)
if #parts == 0 then
local selectedPart = worldParts[math.random(1, #worldParts)]:Clone()
selectedPart.Position = script.Parent.Position
selectedPart.Parent = game.Workspace.World
selectedPart.Mover.Enabled = true
end
wait(.1)
end
and an image of the problem I’m having:
sounds like you are making a never-ending pathway. If the parts are all the same size you could do something like this:
I made a part in the workspace Named “0”, size 12, 1, 12. once touched it fires game.ServerStorage:FindFirstChild(“1”):Clone()
I put a copy of the part in serverStorage and named it 1. with the following script on the part:
local debounce = true
local maxParts = 2
script.Parent.Touched:Connect(function(hit)
local character = hit.Parent:FindFirstChild("Humanoid")
if hit and character and debounce then
debounce = false
local newPart = game.ServerStorage:FindFirstChild("1"):Clone()
newPart.Parent = workspace
newPart.Position = script.Parent.Position + Vector3.new(12, 0, 0)
local nameOfLastPart = tonumber(script.Parent.Name)
newPart.Name = tostring(nameOfLastPart + 1)
local partToDelete = workspace:FindFirstChild(tostring(nameOfLastPart - maxParts))
if partToDelete then
partToDelete:Destroy()
end
end
end)
thank you for your response ! I realised I was overcomplicating it for myself by doing it the way I was so I’m changing how I’m going around it, but I’ll make sure to come back to this if I try it again !