Tweening Problems

  1. What do you want to achieve?
    I would like for both of the doors to both open and close.

  2. What is the issue?
    To be honest I do not know what the issue is, nothing happens when the prompt is triggered, and their for all I am left with is an error that I can’t solve.

image

image

Here is my code

--//Services\\--

local TweenService = game:GetService("TweenService")

--//Extra Variables\\--

local isOpen = false
local debounce = false

--//Tween Info\\--

local DoorInfo = TweenInfo.new(3)

--//Create Goals\\--

local Door1OpenGoal = {}
Door1OpenGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z + 3.8)

local Door2OpenGoal = {}
Door2OpenGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z -3.8)

local Door1CloseGoal = {}
Door1CloseGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z - 3.8)

local Door2CloseGoal = {}
Door2CloseGoal.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z + -3.8)

--//Create Tweens\\--

local Door1Open = TweenService:Create(script.Parent.Door1, DoorInfo, Door1OpenGoal)
local Door2Open = TweenService:Create(script.Parent.Door2, DoorInfo, Door2OpenGoal)
local Door1Close = TweenService:Create(script.Parent.Door1, DoorInfo, Door1CloseGoal)
local Door2Close = TweenService:Create(script.Parent.Door2, DoorInfo, Door2CloseGoal)




function OpenAndCloseDoors ()
	
	if isOpen == false and debounce == false then
		
		debounce = true
		isOpen = true
		
		Door1Open:Play()
		Door2Open:Play()
		
		wait(5)
		
		Door1CloseGoal.Position = script.Parent.Position
		Door2CloseGoal.Position = script.Parent.Position
		
		debounce = false
		
	elseif isOpen == true and debounce == false then
		
		debounce = true
		isOpen = false
		
		Door1Close:Play()
		Door2Close:Play()
		
		wait(5)
		
		debounce = false
		
	end
	
end

script.Parent.KeycardReader1.KeycardReader1Hitbox.ProximityPrompt.Triggered:Connect(OpenAndCloseDoors)
script.Parent.KeycardReader2.KeycardReader2Hitbox.ProximityPrompt.Triggered:Connect(OpenAndCloseDoors)
2 Likes

I believe the error is happening because you are trying to get the Position of a model. In this case the model is called “Door”. Models do not have a Position so this would not work.

Models can however have a primary part, which you can get the CFrame of in many ways.

I know why the error is happening, I just currently can’t think of a solution.
If anyone could add on to this, that would be great.

Anyways, hope this helped.

Hey so I changed it to

Door1Closegoal.Position = script.Parent.Door1.Position
Door2CloseGoal.Position = script.Parent.Door2.Position

but I still get the error.

Door1Closegoal.CFrame = script.Parent.Door1.PrimaryPart.CFrame
Door2CloseGoal.CFrame = script.Parent.Door2.PrimaryPart.CFrame

try this maybe

also make sure your door model has a primary part, you can set it in the properties tab

—Try this

local Door1OpenGoal = {Position=Vector3.new(script.Parent.Position.X,script.Parent.Position.Y, script.Parent.Position.Z + 3.8)}

local Door2OpenGoal = {Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z -3.8)
}

local Door1CloseGoal = {Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z - 3.8)}

local Door2CloseGoal = {Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, script.Parent.Position.Z + -3.8)}

1 Like

The only group is the group called Door, and keycard readers, parts cant have primary parts.

1 Like

But isn’t that the same thing I already had?

1 Like

try this(rewrote your script, idk if it will work but its worth a shot).

--//Services\\--

local TweenService = game:GetService("TweenService")

--//Extra Variables\\--

local isOpen = false
local debounce = false

--//Tween Info\\--

local DoorInfo = TweenInfo.new(3)

--//Door referances\\--

local Door1 = script.Parent.Door1
local Door2 = script.Parent.Door2

--//Create Goals\\--

local Door1OpenGoal = {Position = Door1.Position + Vector3.new(0,0,3.8)}
--Door1OpenGoal.Position = Vector3.new(script.Parent.Door1.Position.X, script.Parent.Door1.Position.Y, script.Parent.Door1.Position.Z + 3.8)

local Door2OpenGoal = {Position = Door2.Position + Vector3.new(0,0,-3.8)}
--Door2OpenGoal.Position = Vector3.new(script.Parent.Door2.Position.X, script.Parent.Door2.Position.Y, script.Parent.Door2.Position.Z -3.8)

local Door1CloseGoal = {Position = Door1.Position + Vector3.new(0,0,-3.8)}
--Door1CloseGoal.Position = Vector3.new(script.Parent.Door1.Position.X, script.Parent.Door1.Position.Y, script.Parent.Door1.Position.Z - 3.8)

local Door2CloseGoal = {Position = Door2.Position + Vector3.new(0,0,3.8)}
--Door2CloseGoal.Position = Vector3.new(script.Parent.Door2.Position.X, script.Parent.Door2.Position.Y, script.Parent.Door2.Position.Z + -3.8)

--//Create Tweens\\--

local Door1Open = TweenService:Create(script.Parent.Door1, DoorInfo, Door1OpenGoal)
local Door2Open = TweenService:Create(script.Parent.Door2, DoorInfo, Door2OpenGoal)
local Door1Close = TweenService:Create(script.Parent.Door1, DoorInfo, Door1CloseGoal)
local Door2Close = TweenService:Create(script.Parent.Door2, DoorInfo, Door2CloseGoal)




function OpenAndCloseDoors ()

	if isOpen == false and debounce == false then

		debounce = true
		isOpen = true

		Door1Open:Play()
		Door2Open:Play()

		wait(5)

		Door1CloseGoal.Position = script.Parent.Position
		Door2CloseGoal.Position = script.Parent.Position

		debounce = false

	elseif isOpen == true and debounce == false then

		debounce = true
		isOpen = false

		Door1Close:Play()
		Door2Close:Play()

		wait(5)

		debounce = false

	end

end

script.Parent.KeycardReader1.KeycardReader1Hitbox.ProximityPrompt.Triggered:Connect(OpenAndCloseDoors)
script.Parent.KeycardReader2.KeycardReader2Hitbox.ProximityPrompt.Triggered:Connect(OpenAndCloseDoors)

Make sure to make a new script and not just copy it to your script right away.and disable the other script.

Both are exactly the same thing.
You can add something to a dictionary in both ways.
For example -

local t = {"number" = 1} 
--and this - 
local t = {} 
t.number = 1
--or you can also do this 
t = {} 
t["number"] = 1 -- This is cleaner

Blockquote

Lua - Tables (tutorialspoint.com)

1 Like

the more you know i guess :D.then what might be the problem he is facing?

@SteveoAttano
I don’t know if you have checked this out or not but here is a really good tutorial by Colbert2677 on tweening models.
Introduction to Tweening Models - Resources / Community Tutorials - DevForum | Roblox

I don’t know if this will help you or not but I hope it does.

Try it ,it will work lol because in your code you were searching door1.door1.

Oh wow it does work can’t belive you wrote the whole script for me lol, thanks. I am gonna look at the difference between the two to see what I done wrong.

Now the only problem is the Closing, it closes, but not the position I want it do despite me reversing what I did when I opened it if that makes sense.

are you making a side sliding door? like when the prompt comes doors slide into the walls or sides.

Their are two halfs of the door, one half goes one way along the X axis, and the other goes the other way. I want it to happen whenever I trigger a prompt.

hmm, unfortunately im unable to understand what kind of a thing you want to achive. can you give me an example like a video or something?

1 Like

hey hey hey i think i might have found the problem.

you see these

local Door1OpenGoal = {Position = Door1.Position + Vector3.new(0,0,3.8)}
--Door1OpenGoal.Position = Vector3.new(script.Parent.Door1.Position.X, script.Parent.Door1.Position.Y, script.Parent.Door1.Position.Z + 3.8)

local Door2OpenGoal = {Position = Door2.Position + Vector3.new(0,0,-3.8)}
--Door2OpenGoal.Position = Vector3.new(script.Parent.Door2.Position.X, script.Parent.Door2.Position.Y, script.Parent.Door2.Position.Z -3.8)

local Door1CloseGoal = {Position = Door1.Position + Vector3.new(0,0,-3.8)}
--Door1CloseGoal.Position = Vector3.new(script.Parent.Door1.Position.X, script.Parent.Door1.Position.Y, script.Parent.Door1.Position.Z - 3.8)

local Door2CloseGoal = {Position = Door2.Position + Vector3.new(0,0,3.8)}

turn the close goals to these

local Door1CloseGoal = {Position = Door1.Position}

local Door2CloseGoal = {Position = Door2.Position}

please try this to see if it fixes your problem.

1 Like

Works perfectly thank you. ------------(had to put extra characters to respond)

1 Like

If there is something you’d like to ask, please ask. I would see if i can help :wink:.

1 Like