Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My lever works but it wont go back to its original spot when clicked? (Solved)

Asked by 3 years ago
Edited 3 years ago

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)

3 answers

Log in to vote
2
Answered by
2_MMZ 1059 Moderation Voter
3 years ago

If you have figured out the answer yourself, congratulations! But be sure to put Solved in your title.

0
Oh okay! DocGooseYT 110 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Never mind, I found out why it didn't work. I fixed it by changing the "isUp" and "isDown" values to IntValues.

Log in to vote
0
Answered by 3 years ago

free rep plis :3

0
I would do it since I'm kind but I don't want my account to be deleted if this isn't allowed sorry. DocGooseYT 110 — 3y
0
@coolnathan its allowed :3 The_Saver31 260 — 3y
0
jk jk The_Saver31 260 — 3y

Answer this question