- What do you want to achieve? Keep it simple and clear!
I’m trying to make a generator system like dead by daylight, where you use a proximity prompt to start working on a generator, and just move to un-interact with the generator. Problem is, you can’t use UIS in server scripts (as far as I’m aware) so I’m using a remote function to go to a local script in StarterPlayerScripts, detect all input during interaction, and if it’s keyboard input, return true back to the server script.
- What is the issue? Include screenshots / videos if possible!
When I print(input.UserInputType == Enum.UserInputType.Keyboard), it prints as true when I use my keyboard during the function, but when I actually compare it and print out the result in the server script, it returns as nil. No matter what I press it shows as nil in the output.
- What solutions have you tried so far? Did you look for solutions on the Creator Hub?
I’ve added a debounce, changed the loop times, tried to isolate the problem like 20 times by now, no matter what I do nothing works, and if it does, a new problem arises. I’ve read the documentation over for functions and UIS, but I don’t see what I’m doing wrong.
The code is down below, and I’ve reviewed it so much and can’t figure out what’s wrong with it, or what concept I’m overlooking, please help me out.
detectInput.OnClientInvoke = function()
if debounce == false then
debounce = true
UIS.InputBegan:Connect(function(input)
print("input began")
print(input.UserInputType == Enum.UserInputType.Keyboard)
if input.UserInputType == Enum.UserInputType.Keyboard then
debounce = false
return true
elseif input.UserInputType ~= Enum.UserInputType.Keyboard then
debounce = false
return false
end
end)
end
end
-- heres where i call the function in a server script
local inputRecieved = false
while inputRecieved == false or inputRecieved == nil do
inputRecieved = detectInput:InvokeClient(plr)
print(inputRecieved)
if inputRecieved == true then
plr.Character.Humanoid.WalkSpeed = 16
usingValue:Destroy()
break
end
task.wait()
end