Hey all, having some trouble with firing a remote event from the User Input Service, and it’s really weird. So, pretty much whenever I move the remote event fires super late for some reason, and decides not to work. I don’t understand what is going on here, please help me out.
Code:
--Services
local uis = game:GetService("UserInputService")
local players = game:GetService("Players")
--Variables
local player = players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local gui = script.Parent
local onEvent = game.ReplicatedStorage:FindFirstChild("BlindfoldOnAnim")
local offEvent = game.ReplicatedStorage:FindFirstChild("BlindfoldOffAnim")
local colorCorrection = game.Lighting.ColorCorrection
--Integers
local actCount = 1
--Bools
local debounce = false
--Script
uis.InputBegan:Connect(function(inpObj, gpe)
if gpe then return end
if debounce == true then return end
debounce = true
if inpObj.KeyCode == Enum.KeyCode.R then
humanoid.WalkSpeed = 0
humanoid.JumpHeight = 0
actCount += 1
print(actCount)
if actCount == 1 then
onEvent:FireServer()
colorCorrection.Enabled = false
else
actCount = 0
offEvent:FireServer()
colorCorrection.Enabled = true
end
task.wait(1)
humanoid.WalkSpeed = 16
humanoid.JumpHeight = 10
debounce = false
end
end)
The remote events are literally just animations that play on the client, and disable an accessory I added to the player. I also realized it was most likely a problem with the local script.