What do you want to achieve? Keep it simple and clear!
So currently i’m working on my new game. When player join there tons of rails add to map one by one, but i can’t clone them next to each other
What is the issue? Include screenshots / videos if possible!
I can’t clone these rails to each other
What solutions have you tried so far? Did you look for solutions on the Developer Hub? I wanted to use primary part and set position of rails spawn
My code:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect((function(player)
local GameInstances = Instance.new("Folder")
GameInstances.Parent = player
GameInstances.Name = "GameInst"
local TrainVal = Instance.new("ObjectValue")
TrainVal.Parent = GameInstances
TrainVal.Name = "PlayerTrain"
local ObjectFolder = game:GetService("ReplicatedStorage")
local RailsModel = ObjectFolder:FindFirstChild("Rails")
local NewRailsModel = RailsModel:Clone()
local FirstRail = game.Workspace.GameFolder.Rails.FirstRail.PrimaryPart
NewRailsModel -- Here idk how to set position
end))
Could you explain what you mean? I meant that when you place a new rail it will take the previous rail’s position and then just add the length of the new rail.
Yes. It would look like that. I made a post a while ago that sort of explains what I mean in a slightly convoluted manner. The code is pretty bad but the concept is there:
If you use the previous part’s position you can make it so that every axis apart from the one you want to move in stays the same.
It’s a bit other thing i don’t need RAILS to move i need to make more RAILS when train moving and in the start when player join there is some rails spawns
Which was what he basically said Can’t you just use the previous rail’s position and then just add/subtract the length on one axis?
also that code that you’re making has a flaw, everytime a player joins it will keep creating rails.
Example code on how you can automize the creation
local Pos = CFrame.new() -- Will start at 0,0,0, up to you to change it.
for i=1, 5 do
local Part = Part:Clone()
Part.CFrame = Pos*CFrame.new(0,0,Part.Size.Z)
Pos = Part.CFrame
Part.Parent = game.Workspace
end
--Will Create 5 Trails as an example.
--The rotation could be wrong so it'll be up to you to modify it.
local part = workspace.Part
local pos = part.Position
for var=1,10 do
wait(1)
local part_ = part:Clone()
part_.Position = Vector3.new(pos.X,pos.Y,pos.Z+part_.Size.Z)
part_.Parent = workspace
part = part_
pos = part_.Position
end