InputObject not working

Hello everyone! I’m trying to make an input key that opens a menu, and it works kinda well, but when I try to add some if condition then the script doesn’t work, and there’s also no errors in the output. Maybe I’m missing something… heres the script:

local UIS = game:GetService("UserInputService")
local Blur = game.Lighting:WaitForChild("Blur")

UIS.InputBegan:Connect(function(InputObject, Processed)
	if InputObject.KeyCode == Enum.KeyCode.M then
		if IsOpen.Value == false and CanOpen.Value == true then
			TS:Create(Blur, TweenInfo.new(.5), {Size = 20}):Play()
			wait(.3)
			TS:Create(PlayerGui.Graphics.Mission, TweenInfo.new(.25), {ImageTransparency = 0}):Play()
			TS:Create(PlayerGui.Graphics.Mission, TweenInfo.new(.25), {Size = UDim2.new(0.382, 0,0.679, 0)}):Play()
			print("Worked")
		elseif IsOpen.Value == true and CanOpen.Value == true then
			TS:Create(Blur, TweenInfo.new(.5), {Size = 0}):Play()
			wait(.3)
			TS:Create(PlayerGui.Graphics.Mission, TweenInfo.new(.25), {ImageTransparency = 1}):Play()
			TS:Create(PlayerGui.Graphics.Mission, TweenInfo.new(.25), {Size = UDim2.new(0.382, 0,0.679, -50)}):Play()
			print("Worked")
		else
			print("Dont")
		end
	end
end)

CanOpen and IsOpen are bool values, so I can change them outside of the script.

You said the canopen is a boolvalue, but I don’t see you checking the value of it.
image

You’re checking the instance.

1 Like

Woah, such a dumb mistake, ty for pointing it out :upside_down_face:
But it’s also not working, I maybe have committed another stupid mistake that I’m not seeing

1 Like

You’re welcome; maybe you could also try

putting

print(tostring(CanOpen.Value).. " canopen value")
print(tostring(IsOpen.Value).. " isopen value")

to see if the values are right

1 Like

Could be useful in the future, but at the moment the script is not running after all, so nothing is printed

1 Like

Is an error message displayed in the output?

1 Like

Unfortunately no :confused:
(Filler text)

You should look into ModuleScripts after you fix this problem. They can store values which every script has access to change and read.

(edit: why is this the solution?)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.