How do You Make a Lever (Using TweenService)

  1. What do you want to achieve? am trying to make my lever switch smoothly

  2. What is the issue? for some reason it ain’t working and there are no errors showing up

  3. What solutions have you tried so far? i tried searching up a tutorial didn’t work tho dev forum is my only hope tbh-

local click = script.Parent.ClickDetector
local model = script.Parent
local endpos = game.Workspace.endpos
local TS = game:GetService("TweenService")

local info = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, 0, false)

click.MouseClick:Connect(function()
	TS:Create(model, info, {CFrame = endpos.CFrame})
	click:Destroy()
end)


am also trying to make the lever a one time use so it shouldn’t work again, thank you in advance <3

1 Like

I think you forgot to play the tween.

Put this instead:

TS:Create(model, info, {CFrame = endpos.CFrame}):Play()
1 Like

try this:

local click = script.Parent.ClickDetector
local model = script.Parent
local endpos = game.Workspace.endpos
local TS = game:GetService("TweenService")

local info = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, 0, false)

click.MouseClick:Connect(function()
	local tween = TS:Create(model, info, {CFrame = endpos.CFrame})
tween:Play()
tween.Completed:Wait()
	click:Destroy()
end)

remove the tween.Completed:Wait() if you don’t want it to finish before deleting.

3 Likes

thank you dude i forgot about that-

1 Like

appreciate it dude forgot about that

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.