In my new game Daylight Towers[BETA] I have been trying to implement a keybind to change a boolean, I have tried this and it doesn’t give me errors but it doesn’t work. I tried using the UIS service but it won’t work. How would I do this, I’m kinda stuck.
Do you mean like pressing a key it changes the boolean value or like pressing CTRL + F changes the boolean value?
I want to press “q” and it changes a boolean
You can use UserInputService
--Simple example
local UIS = game:GetService("UserInputService")
local Boolean = false
local KeyBind = "q" --change to whatever
UIS.InputBegan:Connect(function(key) --function that fires when the localplayer presses a key
if key.KeyCode == Enum.KeyCode[KeyBind] then --if they pressed q
-- change the boolean value
Boolean = true
end
end)
Can you show us the script so that we can help?
local UIS = game:GetService("UserInputService")
local lights = game.ReplicatedStorage.Lights
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
lights.Value = true
end
end)
Have you tried printing the input to see if it’s nil or unknown?
What type of script are you using? Local or Server Sided?
Server sided.
I tried debugging and it turns out its the entire UIS that’s not working
So the part after
isn’t processing, or the function itself.
UIS is only for client. It doesn’t work on server. Try firing a remote event for this.
1 Like