Hi, I've tried to make a "Surface Blast Doors", but my script everytimes make the doors open BUT not open. I use CFrame Lerp and it makes that like the doors are open and not moving, but for roblox it moves, it moves only like a 0.001 stud and I don't know how to fix it. Please help. There is my script.
local db = false local open = false script.Parent.ClickDetector.MouseClick:Connect(function() warn("Checking if SBD's are open..") if open == false then warn("SBD's closed, checking if in move!") if db == false then warn("SBD's not moving. Opening SBD's!") db = true local finish = script.Parent.Parent.PrimaryPart.CFrame*CFrame.Angles(0,math.rad(90),0) for i = 0,1,.00001 do local cfm = script.Parent.Parent.PrimaryPart.CFrame:Lerp(finish,i) script.Parent.Parent:SetPrimaryPartCFrame(cfm) wait() end open = true warn("\nSBD's SUCCESSFULLY OPENED!") wait(1) db = false warn("\nPrepared to close!") end elseif open == true then warn("SBD's opened, checking if in move!") if db == false then warn("SBD's not moving. Closing SBD's!") db = true local finish = script.Parent.Parent.PrimaryPart.CFrame*CFrame.Angles(0,-math.rad(90),0) for i = 0,1,.00001 do local cfm = script.Parent.Parent.PrimaryPart.CFrame:Lerp(finish,i) script.Parent.Parent:SetPrimaryPartCFrame(cfm) wait() end open = false warn("\nSBD's SUCCESSFULLY CLOSED!") wait(1) db = false warn("\nPrepared to open!") end end end)
(The doors itself are the ClickDetector, I made that just for testing.)
The problem is that you are not creating the CFrame from the start point.
Lerp is used to get the % between a start and end values (a CFrame is a list of value) in the value range 0~1 (1 being the end value). You are changing the start point each time resulting in a glichy effect.
Do not change the start or end points while doing the lerp.
-- create a variable of the start point as it should not change local start = script.Parent.Parent.PrimaryPart.CFrame local finish = start * CFrame.Angles(0,-math.rad(90),0) -- lerp from start to finish point for i = 0,1,.00001 do cript.Parent.Parent:SetPrimaryPartCFrame(start:Lerp(finish, i)) wait() end
Hope this helps.