I’ve restarted roblox studio and tested it in a published experience, and it only works whenever the code is incorrect.
its supposed to work like this:
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
if crouchinput == false then
crouchinput = true
else
crouchinput = false
end
print(crouchinput)
end
end)
but only works like this:
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
if crouchinput == false then
crouchinput = true
crouchinput = false
else
end
print(crouchinput)
end
end)
userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
if crouchinput == false then
crouchinput = true
print(crouchinput)
else
crouchinput = false
print(crouchinput)
end
end
end)
edit: on each input it prints both true and false at the same time
if crouchinput == false then
crouchinput = true
else
crouchinput = false
end
into this one line:
crouchinput = not crouchinput
Regardless, the first bit of code should not be giving you the first bit of output at all; it should be the other way around. Are you sure you’re disabling the other section of code when running the game?
Can you please check if crouchinput is being updated elsewhere in the code?
Can you please also add a print just before the InputBegan line, to see how many times it gets setup?