I want to make a Crossy Road type obstacle for a obby please help! (SOLVED)

please look at photo to understand what I am trying to do :slight_smile:


I am trying to find a way to make this van move down the road then when it goes through the black part regen at the other side here’s a pic of the script I got right now
local B = script.Parent.BLACK

local G = script.Parent.GREY

local R = script.Parent.RED

local W = script.Parent.WHITE

local L1 = script.Parent.LIGHT1

local L2 = script.Parent.LIGHT2

wait(2)

function move (x, y, z)

for i=1,1 do

script.B.G.R.W.L1.L2.Position = script.Parent.Position + Vector3.new(x,y,z)

wait(0.1)

end

end

while true do

move(0,0,0)

move(-1,0,0)

end Screen Shot 2021-10-23 at 1.26.26 pm
now this script does not even make it move I am not sure why.

I am new to the forum so if anything in this post makes no sense please let me know.

Also if anyone could show me how to make my thing work and regen that would be great thanks :grinning:

2 Likes

Wrong category, it must be in #help-and-feedback:scripting-support and can you paste the script? to make it easier to copy.

1 Like

Number one this should be in the topic #help-and-feedback:scripting-support

Number 2, you are doing “script.Parent” for everything, but only thing that is referring to is “BLACK”, try moving the script into the model instead of “BLACK”

whoops and also yes I will do that

ok I fixed the topic

and yes good idea that was a mistake

local B = script.Parent.BLACK
local G = script.Parent.GREY
local R = script.Parent.RED
local W = script.Parent.WHITE
local L1 = script.Parent.LIGHT1
local L2 = script.Parent.LIGHT2
wait(2)
function move (x, y, z)
	for i=1,1 do
		script.B.G.R.W.L1.L2.Position = script.Parent.Position + Vector3.new(x,y,z)
		wait(0.1)
	end
end

while true do
	move(0,0,0)
	move(-1,0,0)
end

Just reformatted the script for ease of viewing.

1 Like
local B = script.Parent.BLACK
local G = script.Parent.GREY
local R = script.Parent.RED
local W = script.Parent.WHITE
local L1 = script.Parent.LIGHT1
local L2 = script.Parent.LIGHT2
local RVelements = {B, G, R, W, L1, L2}

function move (x, y, z)
	for _, v in pairs(RVelements) do
		v.Position = script.Parent.Position + Vector3.new(x,y,z)
		wait(1)
	end
end

while wait() do
	move(0,0,0)
	move(-1,0,0)
end

script.B.G.R.W.L1.L2.Position

This bit of code in your original snippet here was the issue. When expanded it would read like this:

script.script.Parent.BLACK.script.Parent.GREY.script.Parent.RED etc...
1 Like

Given that you are just moving the bus (no physics attached), I’d recommend welding together your bus, then use a Tween to move the the whole model from one part of the map to another. You also won’t have to rely on any pesky while wait() do loops if you use a Tween and instead can rely on the more reliable .Completed event for managing the bus object itself.

1 Like

alright that’s a good idea thanks

only thing is the obby I need it for will be randomly generated so it will not all ways be in the same position but the welding and tween is a good idea

Not sure if you’re aware but the 2nd script I posted should work.

Oh thanks I didn’t see it before sorry

Ohhh ok thanks I am not a pro scripter haha

No problem, if it worked feel free to mark the post as the solution. Also you can increase/decrease the number in “wait(1)” to increase/decrease the movement speed of the “REDVAN”.

hmm doesn’t seem to be working not sure why?? I can give you the file for the van if you want it REDVAN.rbxm (12.4 KB)

Do you have any errors that come up in the output?

local B = script.Parent:WaitForChild("BLACK")
local G = script.Parent:WaitForChild("GREY")
local R = script.Parent:WaitForChild("RED")
local W = script.Parent:WaitForChild("WHITE")
local L1 = script.Parent:WaitForChild("LIGHT1")
local L2 = script.Parent:WaitForChild("LIGHT2")
local RVelements = {B, G, R, W, L1, L2}

function move (x, y, z)
	wait(0.1)
	for _, v in pairs(RVelements) do
		print(v)
		v.Position += Vector3.new(x,y,z)
	end
end

while wait() do
	move(0,0,0)
	move(-1,0,0)
end

https://gyazo.com/e723f0c825b7429167c1f1adabfab9f0

1 Like

not that I could see when I was testing

epic! thanks for spending the time to help me