Part won't tween?

local loc = false -- false = down, true = up

local goal = {}
goal.Position = script.Parent.Position + Vector3.new(0,10,0)

local goal2 = {}
goal2.Position = script.Parent.Position - Vector3.new(0,10,0)

local tweenInfo = TweenInfo.new(7.5)

local tweenUp = TweenService:Create(script.Parent, tweenInfo, goal)
local tweenDown = TweenService:Create(script.Parnt, tweenInfo, goal2)

script.Parent.ProximityPrompt.Triggered:Connect(function()
	
	if loc == false then
		script.Parent.Anchored = false
		tweenUp:Play()
		loc = true
		script.Parent.Anchored = true
	elseif loc == true then
		script.Parent.Anchored = false
		tweenDown:Play()
		loc = false
		script.Parent.Anchored = true
	end
	
end)

it doesn’t play the tweens or the tweens aren’t doing anything, here’s a screenshot of it

And the script is under the part, ignore any scripts you see in serverscriptservice most of them are deleted

also i changed script.Parnt to script.Parent

Have you tried inputting the Easing Style and Easing Direction in the TweenInfo.new(7.5)? I think that’s the cause

Okay lemme see what thoes are.e

That isn’t the problem. They default to quad and out I think.

I would recommend adding print statements to see what lines of code are running (this is a common method of debugging code). Also, is there any specific reason that you un-anchor and re-anchor the part? Tweens can move anchored stuff because they’re setting the properties instead of using physics like a body mover. Also, if you’re creating a tweening gate you should probably set one of the goals to the original position and the other to a higher location.

2 Likes

You many have forgotten to add

local TweenService = game:GetService("TweenService")

at the top. You also misspelled Parent here:

local tweenDown = TweenService:Create(script.Parnt, tweenInfo, goal2)

I highly recommend running your code and looking for errors in the output. You can get to the output by going to View → Output. If you misspell something or forgot to declare something the output will tell you.

I addeed tween service and I mentioned that I changed parnt to parent already. There are no errors nor any prints from printing numbers.

I tested it and it worked.

ezgif.com-gif-maker (13)

Code:

local TweenService = game:GetService("TweenService")

local loc = false -- false = down, true = up

local goal = {}
goal.Position = script.Parent.Position + Vector3.new(0,10,0)

local goal2 = {}
goal2.Position = script.Parent.Position - Vector3.new(0,0,0)

local tweenInfo = TweenInfo.new(7.5)

local tweenUp = TweenService:Create(script.Parent, tweenInfo, goal)
local tweenDown = TweenService:Create(script.Parent, tweenInfo, goal2)

script.Parent.ProximityPrompt.Triggered:Connect(function()

	if loc == false then
		script.Parent.Anchored = false
		tweenUp:Play()
		loc = true
		script.Parent.Anchored = true
	elseif loc == true then
		script.Parent.Anchored = false
		tweenDown:Play()
		loc = false
		script.Parent.Anchored = true
	end

end)

It doesn’t work for me, did you anchor the part?

I did both. Both worked. Maybe look into your prompt settings? Also, I would recommend putting the prompt in a button off to the side or inside an invisible part. Having it move with the gate can get difficult.

Here is a working place:
GateExample.rbxl (22.5 KB)

I believe it’s 'cuz Tweens only work on Anchored Parts…

Yeah I anchored it, it sttll doesn’t work.

Try to reinstall your studio? Since its not working for you.

Did you change the script to keep that from Unanchoring it as well?