When a player goes to mine an object, I pause their controls (so they can’t move) and then unpause em when they have finished
However, that causes the character to just start moving in a direction, and I can’t stop them. No matter what keys I press they are stuck moving in that direction. In the video, I am not pressing any keys. I am mashing ASD, but nothing works. Character is locked in a forward momentum, and stuck jumping too (I am not pressing the space bar constantly)
I also do nothing to move the character either. So no MoveTo, etc
Module I use to stop/start movement
local Players = game:GetService('Players')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Player = Players.LocalPlayer
local PlayerControls = require(Player.PlayerScripts.PlayerModule):GetControls()
local SharedModules = ReplicatedStorage:WaitForChild('SharedModules')
local MobileControls = require(SharedModules.MobileControls)
return function(active)
print(active)
if active then
PlayerControls:Enable()
else
PlayerControls:Disable()
end
-- Disable mobile controls
MobileControls.Set(active)
end
‘active’ prints false when I stop movement, and true when I enable it again. This module only gets fired twice in the video (once to stop/once to start movement)
Changing their humanoid properties can easily be changed via exploits. Doing this makes it more difficult for people to do so. This also disables all mobile controls too
Anti-exploit systems are beyond useless. I don’t want to kick someone just for being able to walk/jump when they should be standing still… it’s not a viable reason to kick someone from the game, and end up having them leave a dislike
No, you don’t have to kick them if you don’t want to. You could have the remote function return the walkspeed on the server side, and have the local script make the local walkspeed that
That doesn’t seem so useful to me, its just adjusting the speed after all, plus the Exploiters can change what the remote functions send to the server, so its same as checking what the normal walkspeed should be on Client and changing it if its different.
Disabling controls doesn’t help against exploiters either.
Set WalkSpeed and JumpPower to 0 if it helps you.
If you really want to combat exploiters, Anchor the character’s PrimaryPart from the server so that the server won’t replicate its movement to others.
Can see after the output prints true, my character is still stuck in place. And can see the Jump property flashing a tick, so I’m definately pressing space
return function(active)
print(active)
local Character = Player.Character
if not Character then return end
print(Character)
Character.Humanoid.WalkSpeed = 16 and active or 0
Character.Humanoid.JumpPower = 50 and active or 0
MobileControls.Set(active) -- Disable mobile controls
end
Character.Humanoid.WalkSpeed = 16 and active or 0
Character.Humanoid.JumpPower = 50 and active or 0
This is incorrect. It should’ve been like this:
Character.Humanoid.WalkSpeed = active and 16 or 0
Character.Humanoid.JumpPower = active and 50 or 0
and means that if the value to its left is truthy, it will choose the one to its right, else it will choose the one to its left.
true and 1 and 2 and 3 and 4 and "foo" -- this will be "foo"
true and 1 and 2 and nil and 4 and "foo" -- this will be nil. (nil and 4)
or will choose the value to its left if the left side is truthy, else the right side.
local character = player.Character or player.CharacterAdded:Wait() -- will be player.Character if it isn't nil or false, else will be player.CharacterAdded:Wait()
Combined, they can make a compact if-else statement.
Character.Humanoid.WalkSpeed = active and 16 or 0
-- almost the same as
if active then
Character.Humanoid.WalkSpeed = 16
else
Character.Humanoid.WalkSpeed = 0
end
I did some more testing, and it seems to be due to me destroy a UI element, which has me completely confused. I allow movement, player can move, and I wait say 5 seconds, and then destroy the UI. Once the UI is destroyed, the character is locked in place, for no apparent reason?
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)
UI:Destroy() -- Enabling this prevents movement from fully working?
end
end
Stuck standing still
In this video, once I’ve finished the task, I can move freely. But as soon as the 5 seconds is up and the UI is destroyed, my character either continues moving (if I’m moving when it’s destroyed) or if I stop and then it’s destroyed, they remain stuck in place.
I have no clue why this is occuring. It makes no sense that destroying a UI completely pauses all movement. My movement function is not being called either.