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

Making C-Frame smoother?

I've got a script, yes it works perfectly, but it's blocky. I'm trying to make it smoother, as if it was properly animated.

function click()
if(script.Parent.Status.Value)=="Closed" then
script.Parent.Status.Value="Opening"
local movements=40
local speed=0.1
for i=1,movements do
wait(0.01)
script.Parent.PLT:SetPrimaryPartCFrame(script.Parent.PLT.PrimaryPart.CFrame + Vector3.new(0,0,speed));
end

local sidemoves=250
local sidespeed=0.1
for i=1,sidemoves do
wait(0.01)
script.Parent.PLT:SetPrimaryPartCFrame(script.Parent.PLT.PrimaryPart.CFrame + Vector3.new(sidespeed,0,0));
end
script.Parent.Status.Value="Open"

--negative movement
elseif(script.Parent.Status.Value)=="Open" then
script.Parent.Status.Value="Closing"

local sidemoves=250
local sidespeed=0.1
for i=1,sidemoves do
wait(0.01)
script.Parent.PLT:SetPrimaryPartCFrame(script.Parent.PLT.PrimaryPart.CFrame + Vector3.new(-sidespeed,0,0));
end

local movements=40
local speed=0.1
for i=1,movements do
wait(0.01)
script.Parent.PLT:SetPrimaryPartCFrame(script.Parent.PLT.PrimaryPart.CFrame + Vector3.new(0,0,-speed));
end

script.Parent.Status.Value="Closed"
end

end
script.Parent.Control1.SurfaceGui.TextButton.MouseButton1Click:connect(click)

2 comments

0
0

I don't understand how to use CFrame:lerp()

1 answer

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