I use tweenservice to animate my lever and I have 6 parts in total for my lever, I'm trying to get them to switch back and forth. In my code I programmed it to where it should be able to switch back and forth when clicked but it just stays in the same spot once it gets moved. I apologize for the messy code, I plan to fix it once I can get the code to work.
local SP = script.parent
local D = SP.Demat
local CD = D.Demat.ClickDetector
local isdown = false
local isup = true
local tweenService = game:GetService("TweenService")
local tweeningInformation = TweenInfo.new(
0.4, -- Time
Enum.EasingStyle.Bounce, -- Easing Style
Enum.EasingDirection.InOut, -- Easing Direction
0, -- Number of times it repeats
false, -- If it reverts
0
)
local partProperties = {
Position = Vector3.new(0.245, 6.523, 54.453)
}
local Tween7 = tweenService:Create(D.Demat, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.497, 6.266, 54.287);
CFrame = D.Part1.CFrame * CFrame.Angles(0, -30, 0)
}
local Tween8 = tweenService:Create(D.Part1, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.497, 6.266, 54.287);
CFrame = D.Part2.CFrame * CFrame.Angles(0, -30, 0)
}
local Tween9 = tweenService:Create(D.Part2, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.499, 6.523, 54.454)
}
local Tween10 = tweenService:Create(D.Part3, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.248, 6.523, 54.454)
}
local Tween11 = tweenService:Create(D.Part4, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.009, 6.523, 54.454)
}
local Tween12 = tweenService:Create(D.Part5, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.245, 6.153, 53.309)
}
local Tween = tweenService:Create(D.Demat, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.497, 6.016, 53.615);
CFrame = D.Part1.CFrame * CFrame.Angles(0, 30, 0)
}
local Tween2 = tweenService:Create(D.Part1, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.008, 6.016, 53.615);
CFrame = D.Part1.CFrame * CFrame.Angles(0, 30, 0)
}
local Tween3 = tweenService:Create(D.Part2, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.499, 6.156, 53.305)
}
local Tween4 = tweenService:Create(D.Part3, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.248, 6.156, 53.305)
}
local Tween5 = tweenService:Create(D.Part4, tweeningInformation,partProperties)
local partProperties = {
Position = Vector3.new(0.009, 6.156, 53.305)
}
local Tween6 = tweenService:Create(D.Part5, tweeningInformation,partProperties)
CD.MouseClick:Connect(function()
if isup == true then
Tween:Play()
Tween2:Play()
Tween3:Play()
Tween4:Play()
Tween5:Play()
Tween6:Play()
local isup = false
local isdown = true
else
Tween7:Play()
Tween8:Play()
Tween9:Play()
Tween10:Play()
Tween11:Play()
Tween12:Play()
local isup = true
local isdown = false
end
end)

1 comment
Oh okay!