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

The door I am making won't open at all. Can someone please help?

The door I am trying to make will not open at all. There's no errors, it just won't work. Here's my script..



local fire = game.ReplicatedStorage:WaitForChild("FIREEEE")
local isOpen = false
function open()
	game.Workspace.BIG_DOOR.CFrame = game.Workspace["OPEN FOR DOOR"].CFrame
end
function close()
	game.Workspace.BIG_DOOR.CFrame = game.Workspace["CLOSE FOR DOOR"].CFrame
end
fire.OnServerEvent:Connect(function(plr)
	if isOpen == false then
		open()
		isOpen = true
	end
	if isOpen == true then
		close()
		isOpen = false
	end
end)



2 comments

0

Try adding local to your functions so at lines 3 -6 add local

0

ok, but how will I pass it to the server for everybody to see

3 answers

Lines 10 to 17, if Variable isOpen is false, that means the first if statement is true, but now, since it's true, it will also run the second if statement. I suggest using elseif or else

Sample (else):

local a = true -- change if you want (try using other values like nil or false)
if a==true then
	print'a is true'; --> prints since variable a is true;
else
	print'a is false'; --> does not print since a is true not false or any other value
end;

Sample (elseif):

local a = true -- change if you want
if a==true then
	print'a is true';
elseif a==false then
	print'a is false';
end;

What you did (simplified):

local bool = false;
if bool==false then -- since bool==false this if statement code block runs

	bool = true; -- bool is now truel
end;
if bool==true then -- since bool is now true, this if statement code block also runs

	bool = false; -- bool is now false
end;

1 comment

0

yes, but i am trying to open it

Remember to always put a local before your functions otherwise it wouldn't work Make sure it's serversided Try this code

local isOpen = false
local function open()
    game.Workspace.BIG_DOOR.CFrame = game.Workspace["OPEN FOR DOOR"].CFrame
end
local function close()
    game.Workspace.BIG_DOOR.CFrame = game.Workspace["CLOSE FOR DOOR"].CFrame
end
fire.OnServerEvent:Connect(function(plr)
    if isOpen == false then
        open()
        isOpen = true
    end
    if isOpen == true then
        close()
        isOpen = false
    end
end)



Try using tween movement for your part here is the template just fill it out and edit it as you wish

local TweenService = game:GetService("TweenService")
 
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Color = Color3.new(1, 0, 0)
part.Anchored = true
part.Parent = game.Workspace
 
local goal = {}
goal.Position = Vector3.new(10, 10, 0)
goal.Color = Color3.new(0, 1, 0)
 
local tweenInfo = TweenInfo.new(5)
 
local tween = TweenService:Create(part, tweenInfo, goal)
 
tween:Play()

1 comment

0

oh, thx lol

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