I made a movement disabler control script that disables movement and reenables it if the player is no longer possessed, but it doesn’t reenable most of the time. Why is this?
Script:
local controls2 = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
local controls = game.ReplicatedStorage:WaitForChild("ControlManager")
local cantMove = false
local g
local enabledfalse
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
controls2:Enable(true)
game:GetService("RunService").Heartbeat:Connect(function()
if game.Players.LocalPlayer:FindFirstChild("Possessed") then
if hum and hum.Health > 0 then
controls2:Disable()
elseif hum and hum.Health <= 0 or hum == nil or char == nil then
end
elseif game.Players.LocalPlayer:FindFirstChild("Possessed") == nil then
controls2:Enable(true)
end
end)