I need help on a script that works on experimental mode but does not work on filtering enabled.
Here is the script just in case:
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local KeysDown = {} Mouse.KeyDown:connect(function(Key) if Key:lower() == "w" then KeysDown["w"] = true elseif Key:byte() == 48 then KeysDown["Shift"] = true end if KeysDown["w"] and KeysDown["Shift"] then Player.Character.Humanoid.WalkSpeed = 40 end end) Mouse.KeyUp:connect(function(Key) if Key:lower() == "w" then KeysDown["w"] = false elseif Key:byte() == 48 then KeysDown["Shift"] = false end if not KeysDown["w"] or not KeysDown["Shift"] then Player.Character.Humanoid.WalkSpeed = 16 end end)
Thank You!
Alright, first thing is first: do not use KeyDown or KeyUp, use UserInputService instead.
KeyDown and KeyUp are deprecated, which means they are no longer supported by Roblox and can be removed at any time.
Here is an example of getting input by using UserInputService:
local userInputService = game:GetService("UserInputService") userInputService.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.Q then print("You pressed the Q key!") end end)
It's nearly the same, but better.
Now, about FilteringEnabled. You can make changes to a player's humanoid with a local script and it will replicate to the server. So, that means your script should be working. However, since you stated that it is not a local script and you are using game.Players.LocalPlayer
, there is your issue.
Simply change your script from a server script to a local script, and make sure to use UserInputService. Everything should work afterwards.
The client has network ownership over their respective character, meaning that they can modify some aspects of their character, and still have the change replicated to the server. This means you can change your character's walkspeed locally, and won't have to worry about it not replicating.
local UserInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local sprintWalkspeed, defaultWalkspeed = 34, 16 local sprintHotkey = Enum.KeyCode.LeftShift local function ToggleWalkspeed(isInputBegan) player.Character.Humanoid.WalkSpeed = isInputBegan and sprintWalkSpeed or defaultWalkspeed end UserInputService.InputBegan:Connect(function(input, gameProcessed) if input.KeyCode == sprintHotkey then ToggleWalkspeed(true) end end) UserInputService.InputEnded:Connect(function(input, gameProcessed) if input.KeyCode == sprintHotkey then ToggleWalkspeed(false) end end)