Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Weird glitch that I cannot seem to fix with a door ?

Asked by
Velsity 218 Moderation Voter
4 years ago

local TweenService = game:GetService("TweenService") local door1 = script.Parent.Parent:WaitForChild("Door") local Cooldown = false local Allowed = { "[SCP] A-1 Card", "[SCP] Card-CD", "[SCP] Card-L4", "[SCP] Card-L5", "[SCP] Card-Omni", "[SCP] REDACTED"} local tweeningInformation = TweenInfo.new( 1.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0 ) local door1Open = {CFrame = CFrame.new(-10.937, 3.85, -21.814)} local door1Close = {CFrame = CFrame.new(-5.937, 3.85, -21.814)} local tween1open = TweenService:Create(door1,tweeningInformation,door1Open) local tween1close = TweenService:Create(door1,tweeningInformation,door1Close) script.Parent.Parent.KeycardReader1.Touched:Connect(function(hit) for i, v in pairs(Allowed) do if hit.Parent.Name == v then if Cooldown == false then Cooldown = true script.Parent.DoorOpen:Play() tween1open:Play() wait(2) tween1close:Play() script.Parent.DoorClose:Play() tween1close.Completed:Wait() Cooldown = false end end end end) script.Parent.Parent.KeycardReader2.Touched:Connect(function(hit) for i, v in pairs(Allowed) do if hit.Parent.Name == v then if Cooldown == false then Cooldown = true script.Parent.DoorOpen:Play() tween1open:Play() wait(2) tween1close:Play() script.Parent.DoorClose:Play() tween1close.Completed:Wait() Cooldown = false break end end end end)

https://gyazo.com/c10c98c0947ae4e92369fe2df40269bc

This happens everytime I open the door, how would I fix this?

0
your rotating it...... BashGuy10 384 — 4y
0
you're WideSteal321 773 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

You're tweening the door from whatever its current world orientation is to a CFrame that has identity orientation (0,0,0). You really ought to be expressing the tween goal in terms of the relative change you want, so that the door works even if you re-orient it or move it in the world.

So instead of:

local door1Open = {CFrame = CFrame.new(-10.937, 3.85, -21.814)}
local door1Close = {CFrame = CFrame.new(-5.937, 3.85, -21.814)}

You should have something more like this:

local door1Close = { CFrame = door1.CFrame }
local door1Open = {CFrame = door1.CFrame * CFrame.new(5,0,0) }

This assumes the door starts out closed, and that it needs to slide 5 studs in the direction of its own RightVector when opening. Because I don't know the initial orientation of your door, this offset might not actually be (5,0,0), it might need to be (-5,0,0) or (0,0,5) or (0,0,-5) depending on which side or edge of the door is the Front face of the part. Once you get that translation correct, it will work for any copy of the door no matter where in the world you place it.

That said, in a live game this door is going to stutter because Tweening CFrames from a server script does not get client-side interpolation, so people will see it opening jerkily at about 20fps, not smoothly or linearly like you see it in studio. The preferred way to do a sliding door is with a prismatic constraint and no overlapping collidable parts, because this way everyone will see it smoothly move at 60fps.

Ad

Answer this question