Why does my tween not work?

my game is a single player horror game. this is a regular script. also i am not using otherpart or ontouch type of stuff because this is what i am more comfortable with and it works fine.

local ts = game:GetService("TweenService")

local Eye1 = game.Workspace.Technical:WaitForChild("Eye1")

local Eye2 = game.Workspace.Technical:WaitForChild("Eye2")

local Info = TweenInfo.new (0,

Enum.EasingStyle.Linear,

Enum.EasingDirection.Out

)

local Goal = {Position = Vector3.new(0, -5, 0)}

local Tween = ts:Create(Eye1, Eye2, Info, Goal)

script.Parent.Touched:Connect(function(hit)

if game.Players:FindFirstChild(hit.Parent.Name) then

Tween:Play()

end

end)

also the eyes are supposed to go down.

1 Like

Use Players:GetPlayerFromCharacter instead

You didn’t close the brackets

Upon pasting your code in studio, it appears that you weren’t using speech marks? And that you forgot to close a bracket for the TweenInfo. Did you check the output when it didn’t work?


Anyways, this should fix it:

local ts = game:GetService("TweenService")
local Eyes1 = game.Workspace.Technical:WaitForChild("Eyes1")
local Info = TweenInfo.new (0,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out
)

local Goal = {Position = Vector3.new(0, -5, 0)}
local Tween = ts:Create(Eyes1, Info, Goal)

script.Parent.Touched:Connect(function(hit)
	if game.Players:FindFirstChild(hit.Parent.Name) then
		Tween:Play()
	end
end)

I suggest not separating your code one empty line apart, it makes it harder to read. Also, you didn’t have to do the “0, false, 0” in the TweenInfo since that’s already set by default. And next time, do send your code in a code block. Do this by using the key under the esc key like this:
Screenshot 2022-09-08 at 6.04.54 pm

i did, but it doesn’t show here.

i did close the brackets. i’ll test now. doesn’t work.

Just tested it. The script works if the parts are anchored. Are yours?

yes, they are anchored. at least i know my code should work.

Can you screenshot the script inside the script editor so we can see it better.

Is there a WaitForChild yield in the output? Perhaps Eyes1 isn’t found. If not, is the part you’re trying to tween not in the place it finishes tweening at?

there is a :WaitForChild. Should i wait repeat task.wait() until?

No, that’s basically the same thing. Could you play your game, touch the part, then show me a screenshot of the output so I can see if there’s any errors.

there’s none i looked. i’ll show you anyways



It doesn’t seem to be a problem in the script. Do you by any chance have more than 1 Eyes1 parts?

yeah. i’ve ungrouped them and tried with 1 eye but nothing.

image
both are anchored

script:
image

Why are you putting Eye2 as the second param of ts:Create()? It should be the tween info otherwise it would error, no?
Just create another tween for Eye2 and play that aswell

doesn’t work. i’ve even tried with a random part.

Strange. I have no other ideas left as to why this isn’t working.