Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[Solved] Why do i get an error "TranslateBy is not a valid member of Part"?

Code:

local Car = game.Workspace.Car
local Seats = game.Workspace.Car.Seats:GetChildren() -- Locates the Group of seats in your car
local Gui = script.Parent:FindFirstChild("ExitButton") -- Locates the Exit Button in the Teleport Part
local Gui2 = script.Parent:FindFirstChild("LoadingScreen") -- Locates the Exit Button in the Teleport Part

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			for i,v in pairs(Seats) do
				if Seats.Occupant == nil then
				hit.Parent.Humanoid.JumpPower = 0
				hit.Parent.Humanoid.WalkSpeed = 0
				Gui:Clone().Parent = player.PlayerGui
				player.Character.HumanoidRootPart.CFrame = Seats[math.random(1,12)].CFrame -- Teleports the player to a vacant seat
				wait(10)
				player.PlayerGui.ExitButton:Destroy()
				for i = 1,100 do -- Moves the car forward
					Car:TranslateBy(Vector3.new(0,0,-1))
					wait() -- Do not change this line
				end
                Gui2:Clone().Parent = player.PlayerGui
                player.Character.Humanoid.JumpPower = 50
                wait(0.2)
                player.Character.Humanoid.Jump = true
                wait(0.2)
                player.Character.Humanoid.JumpPower = 0
                wait(0.2)
				wait()
				player.Character.HumanoidRootPart.CFrame = game.Workspace.GameTeleporter.CFrame -- Teleports the player to the Game Teleport brick
				wait(1)
				player.Character.Humanoid.JumpPower = 50
                wait(0.2)
                player.Character.Humanoid.Jump = true
                wait(0.2)
                player.Character.Humanoid.JumpPower = 0
				wait(15)
				for i = 1,100 do -- Moves Car Reverse
					Car:TranslateBy(Vector3.new(0,0,1)) -- You might have to move the 1 in the position of a 0
					wait() -- Do not change this line
				end
			end
		end
	end
end)

workspace:https://imgur.com/a/kCDGcVR

I watched this vid as a tut: https://www.youtube.com/watch?v=27nHlMvmbek

1 answer

Fixed it, the car had to be a model / group not a part

This discussion is preserved as it was. New answers, comments, and votes are closed.