n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:08pm
#1
Hello, I am trying to make this door script using tweening and so far its been going good. But I’ve encountered this error of the door not opening correctly and instead just dragging it to the fake door.
If anyone can figure this out please put it in the comments thanks
wf_sh
(wait)
July 24, 2022, 7:09pm
#2
Perhaps post your script(s) when posting a submission in scripting support
n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:09pm
#3
script.Parent.Touched:Connect(function(hit)
if table.find(acceptableOpeners, hit.Parent.Name) then
script.Parent.GateOpen:Play()
local OpenTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = fakeDoor1Position})
OpenTween1:Play()
script.Parent.Light.BrickColor = BrickColor.new("Lime green")
script.Parent.Accepted:Play()
script.Parent.Accepted.Looped = false
task.wait(5)
script.Parent.GateClosed:Play()
local CloseTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = door1Position})
CloseTween1:Play()
script.Parent.Light.BrickColor = BrickColor.new("Really red")
end
end)
wf_sh
(wait)
July 24, 2022, 7:10pm
#4
Tween their CFrame instead of Position.
n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:11pm
#5
What do you mean tween their CFrame?
wf_sh
(wait)
July 24, 2022, 7:18pm
#6
You are tweening the parts position, but not their orientation. All parts have a CFrame property which is made out of a parts position and various rotational components.
By tweening the CFrame instead of Position you will also be changing orientation, you are not currently.
e.g change {Position = door1Position}
to {CFrame = door1CFrame}
n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:20pm
#7
It started to give me this error
wf_sh
(wait)
July 24, 2022, 7:22pm
#8
Your variable door1Position
is a Vector3.
Go back in your code to when you assign its value, instead of setting door1Position
to something such as Part.Position
set it to Part.CFrame
n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:25pm
#10
Oh wait I think I figured it out
n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:26pm
#11
Nevermind I it’s still giving me the error.
monkted0
(Monkted)
July 24, 2022, 7:34pm
#12
Can you show the whole script I’m pretty sure door1position = a position value it just has to be the door value so door.CFrame not Doorposition.CFrame
n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:35pm
#13
--//Services
local TweenService = game:GetService("TweenService")
local acceptableOpeners = {"LL Keycard", "Keycard", "LI Keycard", "LV Keycard", "LX Keycard", "LO Keycard"}
--//Variables
local Model = script.Parent
local ActualDoor1 = Model.RealDoor
local FakeDoor1 = Model.FakeDoor
--//Controls
local door1Position = ActualDoor1.CFrame
local fakeDoor1Position = FakeDoor1.CFrame
--//Functions
script.Parent.Touched:Connect(function(hit)
if table.find(acceptableOpeners, hit.Parent.Name) then
script.Parent.GateOpen:Play()
local OpenTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = fakeDoor1Position})
OpenTween1:Play()
script.Parent.Light.BrickColor = BrickColor.new("Lime green")
script.Parent.Accepted:Play()
script.Parent.Accepted.Looped = false
task.wait(5)
script.Parent.GateClosed:Play()
local CloseTween1 = TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {Position = door1Position})
CloseTween1:Play()
script.Parent.Light.BrickColor = BrickColor.new("Really red")
end
end)
n4dar
(jerbawesomelife_yt)
July 24, 2022, 7:47pm
#14
it says Unable to cast to dictionary
wf_sh
(wait)
July 24, 2022, 8:14pm
#15
--//Services
local TweenService = game:GetService("TweenService")
local acceptableOpeners = {"LL Keycard", "Keycard", "LI Keycard", "LV Keycard", "LX Keycard", "LO Keycard"}
--//Variables
local Model = script.Parent
local ActualDoor1 = Model.RealDoor
local FakeDoor1 = Model.FakeDoor
--//Controls
local door1CFrame = ActualDoor1.CFrame
local fakeDoor1CFrame = FakeDoor1.CFrame
--//Functions
script.Parent.Touched:Connect(function(hit)
if table.find(acceptableOpeners, hit.Parent.Name) then
Model.GateOpen:Play()
TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = fakeDoor1CFrame}):Play()
Model.Light.BrickColor = BrickColor.new("Lime green")
Model.Accepted:Play()
Model.Accepted.Looped = false
task.wait(5)
script.Parent.GateClosed:Play()
TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = door1CFrame}):Play()
Model.Light.BrickColor = BrickColor.new("Really red")
end
end)
2 Likes
monkted0
(Monkted)
July 24, 2022, 8:34pm
#16
Oh yeah I forgot to say make sure to change position to CFrame
1 Like
You could try this:
local TweenService = game:GetService("TweenService")
local door = game.Workspace.Door
local doorPlaceholder = game.Workspace.DoorPlaceholder
local goal = {}
goal.CFrame = doorPlaceholder.CFrame
local openTime = .5
local tweenInfo = TweenInfo.new(openTime)
local tween = TweenService:Create(door, tweenInfo, goal)
tween:Play()
Or if door is a model, set a primary part and weld all other parts to the primary part, then try this one instead:
local TweenService = game:GetService("TweenService")
local door = game.Workspace.Door.PrimaryPart
local doorPlaceholder = game.Workspace.DoorPlaceholder.PrimaryPart
local goal = {}
goal.CFrame = doorPlaceholder.CFrame
local openTime = .5
local tweenInfo = TweenInfo.new(openTime)
local tween = TweenService:Create(door, tweenInfo, goal)
tween:Play()
1 Like
n4dar
(jerbawesomelife_yt)
July 24, 2022, 11:55pm
#18
wf_sh:
--//Services
local TweenService = game:GetService("TweenService")
local acceptableOpeners = {"LL Keycard", "Keycard", "LI Keycard", "LV Keycard", "LX Keycard", "LO Keycard"}
--//Variables
local Model = script.Parent
local ActualDoor1 = Model.RealDoor
local FakeDoor1 = Model.FakeDoor
--//Controls
local door1CFrame = ActualDoor1.CFrame
local fakeDoor1CFrame = FakeDoor1.CFrame
--//Functions
script.Parent.Touched:Connect(function(hit)
if table.find(acceptableOpeners, hit.Parent.Name) then
Model.GateOpen:Play()
TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = fakeDoor1CFrame}):Play()
Model.Light.BrickColor = BrickColor.new("Lime green")
Model.Accepted:Play()
Model.Accepted.Looped = false
task.wait(5)
script.Parent.GateClosed:Play()
TweenService:Create(ActualDoor1, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = door1CFrame}):Play()
Model.Light.BrickColor = BrickColor.new("Really red")
end
end)
Sorry for the late reply but thanks this worked.