Cars not moving in plugin script

this might sound wierd, but im making a plugin in which a game is inside it, and i want to move my 2D car, the current script(for cars)

while true do
			score += 5
			gamediskgui.avoidcars_minigame.score.Text = "Score : "..score
			--spawn cars
			local car = gamediskgui.avoidcars_minigame.gras.road.car1:Clone()
			car.Parent = gamediskgui.avoidcars_minigame.gras.road.movingcars
			coroutine.wrap(function()
				local mycar = car
				local function CheckCollision(p1,p2)
					if (p1.AbsolutePosition.X < p2.AbsolutePosition.X + p2.AbsoluteSize.X and p1.AbsolutePosition.X > p2.AbsolutePosition.X - p2.AbsoluteSize.X) and (p1.AbsolutePosition.Y < p2.AbsolutePosition.Y + p2.AbsoluteSize.Y and p1.AbsolutePosition.Y > p2.AbsolutePosition.Y - p2.AbsoluteSize.X) then
						return true
					else
						return false
					end
				end
		 while true do
				mycar.Position -= UDim2.new(1,0,0,0)
		 		if CheckCollision(mycar,gamediskgui.avoidcars_minigame.gras.road.player) then
		 			gamediskgui.avoidcars_minigame.gras.road.Died:Fire()
				end
		 		if CheckCollision(mycar,gamediskgui.avoidcars_minigame.gras.road.maxdist) then
		 			pcall(function()
		 				mycar:Destroy()
					end)
					break
				end
				task.wait(0.1)
			end
		end)
		car.Visible = true
		task.wait(2)
		local car2 = gamediskgui.avoidcars_minigame.gras.road.car2:Clone()
		car2.Parent = gamediskgui.avoidcars_minigame.gras.road.movingcars
		coroutine.wrap(function()
			local mycar = car2
			local function CheckCollision(p1,p2)
				if (p1.AbsolutePosition.X < p2.AbsolutePosition.X + p2.AbsoluteSize.X and p1.AbsolutePosition.X > p2.AbsolutePosition.X - p2.AbsoluteSize.X) and (p1.AbsolutePosition.Y < p2.AbsolutePosition.Y + p2.AbsoluteSize.Y and p1.AbsolutePosition.Y > p2.AbsolutePosition.Y - p2.AbsoluteSize.X) then
					return true
				else
					return false
				end
			end
			while true do
				mycar.Position -= UDim2.new(1,0,0,0)
				if CheckCollision(mycar,gamediskgui.avoidcars_minigame.gras.road.player) then
					gamediskgui.avoidcars_minigame.gras.road.Died:Fire()
				end
				if CheckCollision(mycar,gamediskgui.avoidcars_minigame.gras.road.maxdist) then
					pcall(function()
						mycar:Destroy()
					end)
					break
				end
         			task.wait(0.1)
			end
	    end)
		car2.Visible = true
		if stoppedplaying then
			break
		end
		task.wait(2)
	end

vid

as you see, the red things(the cars) are not moving

Thanks y’all for ignoring me, however I fixed this.

1 Like