✓ Accepted answer
Hey Antux,
From what I understand of the purpose of your script is, there's a button(where it be a Gui or a Part doesn't matter, for this example I'm going to use a Part button) and when somebody presses that button the part goes up a certain amount of studs and when somebody presses the part again, the part comes back down a certain amount of studs. This is just some very simple tweening between CFrames/Positions. I'm going to show you how to do this below using TweenService.
local detector = script.Parent;
local tween_service = game:GetService("TweenService")
local curtain = workspace:WaitForChild("Curtain");
local old_pos = curtain.CFrame;
local first = false;
local info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut);
local y = 50;
local cframe;
function move_part()
if first == false then
first = true;
cframe = old_pos * CFrame.new(0, y, 0)
else
first = false;
cframe = old_pos;
end
local goal = {CFrame = cframe};
local tween = tween_service:Create(curtain, info, goal);
tween:Play();
end
detector.MouseClick:Connect(move_part);
Updated the script 'cause the old one had issues.
##Well, I hope I helped and have a great day/night.
~~ KingLoneCat
1 comment
accept KingLoneCat's answer, he said you copied it without accepting it. It's just unfair to the person who coded the answer but they get no reputation.