My output says my controlsenabled is on but when I try to move, it doesn’t work
However whenever I change movement mode (such as click to move) and then use it, my controls work again?
I’m not sure if this is a bug or something wrong with my code:
local Players = game:GetService("Players")
local function onCharacterAdded(player, character)
local plrscripts = player:WaitForChild("PlayerScripts")
local module = require(plrscripts:WaitForChild("PlayerModule"))
local controls = module:GetControls()
if player:GetAttribute("Menu") == true then
if player.PlayerGui:FindFirstChild("StaminaGui") then
player.PlayerGui.StaminaGui.Enabled = false
end
controls:Disable()
print("Controls disabled for player:", player.Name)
else
if player.PlayerGui:FindFirstChild("StaminaGui") then
player.PlayerGui.StaminaGui.Enabled = true
end
if controls.controlsEnabled == false or controls.controlsEnabled == nil then
controls:Enable(true)
print("Controls enabled for player:", player.Name)
end
end
print(controls.controlsEnabled)
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(function(character)
onCharacterAdded(player, character)
end)
-- If character already exists (player joined after respawn), handle it
if player.Character then
onCharacterAdded(player, player.Character)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
-- Handle players already in game
for _, player in Players:GetPlayers() do
onPlayerAdded(player)
end