In my script, I was trying to do something like this: So if you press "T" the script will check the value of a value, if the value is 0 it will proceed but if the value is 1 it will reset and will not do the rest. The rest of the script adds to the value, so like I said before if the value is 0 it would proceed, meaning it will change the value to 1.
function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.T then if game.Workspace.Tsundere.Value == 1 then game.Workspace.Tsundere.Value = 0 else game.Workspace.Tsundere.Value = (game.Workspace.Tsundere.Value +1) end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
I'm not sure but I can help you edit your script and it may work, there are ways to help you improve that script;
local uis = game:GetService("UserInputService") --Make a variable instead local T = game.Workspace:WaitForChild('Tsundere') --Make variable and use WaitForChild to wait for it to load in first uis.InputBegan:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.T then if T.Value == 1 then T.Value = 0 if T.Value == 0 then T.Value = 1 end end end end)
This is much easier and simple to understand. I might have a made a mistake in the code but you can fix it. \ NOTES:
- Make sure this is a
LocalScript
Inside ofStarterPlayerScripts
- Make sure Tsundere's Value is actually 1
- IF It still doesn't work try adding prints to find problems
- Make sure all the conditions are met
Anyway if I was able to help then please accept answer.
Good luck developing!