How would I go about to making a moving background that repeats itself. Similar to the trains make in average plate gaem - [đź“‹ QUESTS +] average plate gaem - Roblox
- Have a background
- Clone it and put it “after” the first background.
UI: Make sure the clone.Parent = original and clone.Size = UDim2.fromScale(1, 1)
Model: Weld the clones primary part to originals primary part - Tween the background to the start of the clone, then teleport the background to the start of the original and repeat
As I’m a new fairly new scripter, Could you provide me with an example.
-- UI Example
local TS = game:GetService("TweenService")
local background = script.Parent.Background -- have a background
local extension = background:Clone() -- Clone the backround
extension.Size = UDim2.fromScale(1, 1) -- Set scale
extension.Parent = background -- & parent
local targetPosition = UDim2.fromScale(1, 0)
local originalPosition = background.Position
-- Create tween:
local movement = TS:Create(background, TweenInfo.new(5, Enum.EasingStyle.Linear), { Position = targetPosition })
movement.Completed:Connect(function()
background.Position = originalPosition -- Once tweened, reset position of background
movement:Play() -- Replay it
end)
movement:Play() -- Play movement
Sorry, I should’ve been more specific. The trains map in “average plate gaem” the background as in parts. The train isn’t moving. but the walls and floor of the map are moving, hence giving the illusion of a moving background
The principle is still the same. Do these tasks and you should be able to complete your goal:
- Have your part
A
and clone it (clone =B
). WeldB
toA
, then tween A using CFrame.B
should follow, if it doesn’t, make sureB
isn’t anchored. - Try tweening a model (Tip: Weld & un-anchor all parts except the primary part, use what you learned in previous task to guess what will happen)
- Clone the model and weld the primary part of cloned model to primary part of original part
My friend helped me make this, but we cant figure out why it wont move and clone
local wallCount = 0
local maxWalls = 40
local wallSpeed = 1
local partA = workspace.PartA
local partAClone = partA:Clone()
partAClone.Parent = workspace
local function moveWall()
local endPos = partA.Position - Vector3.new(0, 0, 10)
local tweenInfo = TweenInfo.new((partA.Position - endPos).Magnitude / wallSpeed, Enum.EasingStyle.Linear)
local tween = game:GetService("TweenService"):Create(partA, tweenInfo, {Position = endPos})
tween:Play()
tween.Completed:Connect(function()
partA.Position = partAClone.Position
moveWall()
end)
end
while wallCount < maxWalls do
wallCount = wallCount + 1
local newWall = partAClone:Clone()
newWall.Parent = workspace
newWall.CFrame = partAClone.CFrame + Vector3.new(0, 0, -10 * wallCount)
newWall.Anchored = true
newWall.CanCollide = true
end
partA:Destroy()
moveWall()
When you can, please reply to this.
Pardon my late response, I didn’t get a notification that you had replied to this!
It is because you destroy partA right before you call the function moveWall, which means moveWall won’t have a part to move.
You also need to weld the new walls to the previous walls, else they will not move together with it.
Thank you so much, this helped alot.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.