Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to create automatic opening curtains?

So I'm creating a theater where the show will be run by a script. One thing i have are curtains that will automatically open when the show begins. Now I have a script to open the curtains, unfortunately, it's not quite how I want them to open. Instead of the curtains sliding open, they suddenly open which doesn't look really good. I need the curtains to slide open but I don't really know what else I need to do with my script. Heres some part of the script for the curtains

SD1 = game.Workspace.StageDoor1
while true do 
	wait(4)
	    for i = 0,15,0.1 do
	    SD1.CFrame = SD1.CFrame*CFrame.new(0,(0.9*9),0) 
end 

Im sure I probably got some numbers mixed and I know for sure that I'm missing some scripts but I don't know what. by the way, this script is not located inside a part or model.

2 comments

0

Use Tweening.

0

wow thanks that totally helped... not

1 answer

✓ Accepted answer

Before I begin, I would like to suggest not being so rude in the comments to people who are trying to help you.

I am going to assume for the below examples that "StageDoor" is a single part, as referenced by how you are using it in your current code (Models do not have CFrames on their own).

The main issue with your current code is that you are using a for-loop, which means if you want to space out the changes in the CFrame, you will have to add a wait() inside of the iteration, otherwise, it will occur at a rate of 0 seconds for each change (a sudden movement)

Server Script / Local Script

while true do
	wait(4)
	for i = 0, 15, 0.1 do
		SD1.CFrame = SD1.CFrame * CFrame.new(0,(0.9 * 9),0)
		wait()
	end
end

Unless your "show" is only 4 seconds long, I am going to suggest removing the while-loop, unless this is only a portion of the script that starts the show and there are other lines which have not been written in your question (there was not a second "end" at the end of the code?)

Another option you have available to use is the TweenService, as stated in the comments, which is used to make smooth transitions. If we were to use the wait() in your above line of code, this would become 4.5 seconds of waiting, which is what I will be using for the time the tween takes to finish.

Server Script / Local Script

local TweenService = game:GetService("TweenService")
local timer = 4.5
local tweenInfo = TweenInfo.new(timer)

local goal = {}
goal.CFrame = SD1.CFrame * CFrame.new(0, (0.9 * 9), 0) * (15 / 0.1)
local SD1 = workspace.StageDoor1
local tween = TweenService:Create(SD1, tweenInfo, goal)

while true do
	wait(4)
	tween:Play()
	wait(timer)
end

Also, you can use game:GetService("Workspace") or the preferred workspace instead of game.Workspace

4 comments

0

wasnt being rude, just telling me to do this without providing an example or reference isnt gonna help me

0

the sarcasm, anyway, does this answer clarify things for you?

0

unfortunately im getting this error "Workspace.DoorUp:6: attempt to index global 'SD1' (a nil value)"

1

never mind i managed to get it to work, thanks a lot

This discussion is preserved as it was. New answers, comments, and votes are closed.