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

I want to make a door using servo type hinge but its wrong, can someone help me?

local hinge = script.Parent.Frame.Hinge
local door = script.Parent.Door
local handle1 = script.Parent.Handle1
local handle2 = script.Parent.Handle2
local targetAngle = -90
local open = false

local function DoorFunction ()
	if open == false then
		hinge.TargetAngle = 0
		open = true
		print("open")
	end
	if open == true then
		hinge.TargetAngle = targetAngle
		open = false
		print("close")
	end
end

handle1.ClickDetector.MouseClick:connect(DoorFunction)
handle2.ClickDetector.MouseClick:connect(DoorFunction)

i want to make the door opens when the handle is clicked and closes when the handle is clicked again

PLS help!

1 answer

✓ Accepted answer

I just connected the 2 'if's, if open is false then it read the statement(Updates 'open' to true) and reads another condition which checks if open is true... gotta stop here, bai

http://wiki.roblox.com/index.php?title=Conditional_statement#Elseif

local hinge = script.Parent.Frame.Hinge
local door = script.Parent.Door
local handle1 = script.Parent.Handle1
local handle2 = script.Parent.Handle2
local targetAngle = -90
local open = false

local function DoorFunction ()
    if open == false then
        hinge.TargetAngle = 0
        open = true
        print("open")

    elseif open == true then
        hinge.TargetAngle = targetAngle
        open = false
        print("close")
    end
end
end

handle1.ClickDetector.MouseClick:connect(DoorFunction)
handle2.ClickDetector.MouseClick:connect(DoorFunction)

2 comments

0

:(

0

Thx for the help! Now i can make a lot of things using this. : )

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