Tween Script Error

I’m made a tween script and it’s not working. The cursor for the ClickDetector won’t even show up.

function onClicked(playerWhoClicked)
	local TweenService = game:GetService("TweenService") --gets service for tween
	local tweenModel = game.Workspace.FrontLift --the part you want to tween (you can change this)

	local info = TweenInfo.new(
		5,           --seconds it takes to complete loop
		Enum.EasingStyle.Quad,     --easingstyle (how it moves)
		Enum.EasingDirection.InOut,    --easingdirection (which direction)
		0,                    --times repeated (negative number if u want infinite)
		false,                 --reverse (does it go back to its spot)
		0                      --delay time (stoptime before doing the tween)
	)

	local Goals = {             
		Position = tweenModel.Up.Position

	}

	local PartTween = TweenService:Create(tweenModel.Lift, info, Goals) --gets all the info and goals and creates tween
	PartTween:Play() --plays it

end


script.Parent.ClickDetector.MouseClick:connect(onClicked)

image
Button Above ^^^

I believe having a ClickDetector and a SuefaceGui might cause some confusion for us.

How is the onClicked event fired? I’m guessing it’s through the ClickDetector.

So, first, let’s do basic debugging. Change the Enabled property of the SurfaceGui to false, and let me know how it goes for you. If this is the problem, you will have to find a workaround to having your SurfaceGui shown, which I think is setting the Active property of the TextLabel to false.

And, as always, is the onClicked event actually connected to the ClickDetector?

As a side note I recommend saving your TweenInfo outside of the function as it is slightly faster and you don’t need to change it multiple times.

It’s still now working with disabling it and full-on deleting the SurfaceGui.

Would you mind posting a copy of the model so I can do some debugging?

Nothing in your code is incorrect, but there seems to be an issue with your Code or Click Detector, but there is an issue with your “UP” part, as it’s at the exact same point as the platform, which is the reason no movement occurs.

Not a single word just made sense there.

i love how he capitalized Code, all scripters do that (even me)

In all seriousness, did you check if tweenModel.Up is actually not falling? If your Code is incorrect, it wouldn’t be tweening at all. Try a different EasingStyle.

To do further debugging within your Code, you can call the function instantly without the ClickDetector to make sure it’s working properly.

It’s literally only an issue with a part called “Up” in the model. It’s not even positioned further up from the platform itself.

1 Like