When I destroy this UI element, it causes my player to completely freeze and movement completely stops. For no reason. I do have a function that I use to enable/disable movement. However, even tho I enable it in this code (And don’t disable it ever again) the player still has controls taken away from them.
In my code, I put a wait(5)
to basically show that destroying the UI is what’s causing this issue. As after Movement(true
) is fired, I can run around freely. But as soon as the UI is destroyed, my character is locked in place.
When I am spamming the camera movement, that is when I am also mashing the keyboard, trying to get some movement from my character, to no avail.
local function InputBegan(input, GPE)
if GPE then return end
if input.UserInputType ~= Enum.UserInputType.MouseButton1 and input.UserInputType ~= Enum.UserInputType.Touch then return end
if not Crystal:FindFirstChild("HP") then return end -- HP does not exist
Crystal.HP.Value -= 1
if Crystal.HP.Value <= 0 then
Mined:FireServer(Crystal)
Crystal:Destroy()
Movement(true) -- Enable movement
CameraManipulation.Reset()
-- Set values to nil
CurrentInteraction.Value = nil
Mining.Value = nil
wait(5)
print("DESTROY")
UI:Destroy() -- This prevents movement from fully working?
end
end
UserInputService.InputBegan:Connect(InputBegan)
return function(active)
print("MOVEMENT IS BEING SET TO: ", active)
if active then
PlayerControls:Enable()
else
PlayerControls:Disable()
end
MobileControls.Set(active) -- Disable mobile controls
end
Output
23:37:22.204 MOVEMENT IS BEING SET TO: false - Client - Movement:17
23:37:23.305 MOVEMENT IS BEING SET TO: true - Client - Movement:17
23:37:28.322 DESTROY - Client
As you can, the movement function NEVER fires false, after it’s fired as true. So it’s last time being fired is true, thus movement should stay active.