Hey there I am having a small issue, the goal is the disable the users controls while their character attribute called IsCombat is true, but the moment it becomes false the user needs to press on “w” or “s” again to be able to move. It’s ruining the flow of the combat. Any idea how to fix that?
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local playerScripts = localPlayer:WaitForChild("PlayerScripts")
local PlayerModule = require(playerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()
character:GetAttributeChangedSignal("AirCombat"):Connect(function()
if character:GetAttribute("AirCombat") then
Controls:Disable()
else
task.wait(0.1)
Controls:Enable()
end
end)
localPlayer.CharacterAdded:Connect(function(newCharacter)
character = newCharacter
end)