Here is what I’m working with:
Two objects, One door, and an IntValue in the workspace
Both objects have to be open in order for the door to be unlocked, the door is checking if the IntValue located in the workspace = 2 in order to be unlocked.
But I can’t for the life of me figure out how I even add to the value in the first place.
Code inside the objects
same across both, so when both are opened, the IntValue should be at 2.
local SecretDoorValue = game.Workspace.CliffDoorValue.Value -- The value of the IntValue object
local Opened = false
local X = script.Parent:WaitForChild("Assembly")
local Prompt = script.Parent.Assembly.Top:WaitForChild("ProximityPrompt")
function OpenDoor()
if Opened == false then
Opened = true
SecretDoorValue = SecretDoorValue + 1 -- Add to the IntValue's value
Prompt.Enabled = false
for i = 1, 54 do
X:TranslateBy(Vector3.new(0, 0.08, 0))
wait()
end
Prompt.ActionText=("Close")
Prompt.Enabled = true
else
Opened = false
SecretDoorValue = SecretDoorValue - 1 -- Subtract from the IntValue's value
Prompt.Enabled = false
for i = 1, 54 do
X:TranslateBy(Vector3.new(0, -0.08, 0))
wait()
end
wait()
Prompt.ActionText=("Open")
Prompt.Enabled = true
end
end
Prompt.Triggered:Connect(function(Players)
OpenDoor()
end)
My problem as of now is trying to actually add/subtract to the IntValue… nothing happens at all.
Script inside the door to be unlocked
local SecretDoorValue = game.Workspace.CliffDoorValue
local Door = script.Parent
if SecretDoorValue.Value == 2 then
Door.ProximityPrompt.Enabled = true
elseif SecretDoorValue.Value ~= 2 then
Door.ProximityPrompt.Enabled = false
end