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

Move A Model Up And Down Smoothly?

Hi folks, I've been trying to work on a set of Bollards that move down when a car has touched the sensor and that it goes back up after 5 seconds it touched it. Here's the code:

Debounce = false
script.Parent.Touched:connect(function(Rise)
	if Debounce == true then return end
	Debounce = true
	if Rise.Parent:FindFirstChild("VehicleSeat")then
		for Move = 1,5 do
		script.Parent.Parent.Bollards:MoveTo(script.Parent.Parent.Bollards:GetModelCFrame().p + Vector3.new(0, -1, 0))
		wait()
		end
		wait(4)
		for Move = 1,5 do
		script.Parent.Parent.Bollards:MoveTo(script.Parent.Parent.Bollards:GetModelCFrame().p + Vector3.new(0, 1, 0))
		wait()
		Debounce = false
		end
	end
end)

Any help will be much appreciated! Thanks!

2 answers

Take a look at this Document it will help pretty good : Document

1 comment

0

Thanks but this isn't what I was looking for. I know how to slide parts, but with a Model is a lot harder. Anyway, thanks for trying!

SetPrimaryPartCFrame This wonderful thing I discovered has worked like a treat for many of my buildings.

"How to use this?", I hear you ask. Iincorporate it with loops.

local studsToTravel = 10 --For example
local speed = 0.2 --How many studs every loop
local RealMovements = studsToTravel / speed
local model = workspace.LeModel

for i = 1,RealMovements do
	wait(0.001)
	model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame + Vector3.new(0,speed,0));
end

Hope I helped!

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