local Player = game:GetService('Players').LocalPlayer local Mouse = Player:GetMouse() local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild('Humanoid') local ls = game.Players.LocalPlayer:WaitForChild('leaderstats') local power = ls.Power function PressC(key) if (key == "c") then if power.Value == 'Super Speed' then do if Humanoid.WalkSpeed == 16 then Humanoid.WalkSpeed = 50 script.Parent.Text = 'Click to Slow Down' elseif Humanoid.WalkSpeed == 50 then Humanoid.WalkSpeed = 16 script.Parent.Text = 'Click to Speed Up' end end end end Mouse.KeyDown:connect(PressC)
When I press C it does not change my speed!
Hi, I'm BlackOrange and today I will be helping you out.
- You are manipulating Humanoid WalkSpeed on the
Client
- You are using deprecated code (Keydown and :connect)
Assuming your game is FilteringEnabled
, you will need RemoteEvent
To Start: Add a Script
into ServerScriptService
Now add a LocalScript
to StarterCharacterScripts
(It's in StarterPlayer)
Edit the Script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr) -- when a signal is recieved local Char = plr.Character or plr.CharacterAdded:Wait() -- get character local Humanoid = Char:WaitForChild('Humanoid') if Humanoid.WalkSpeed = 16 then Humanoid.WalkSpeed = 50 else Humanoid.WalkSpeed = 16 end end)
Now in the local script:
local plr = game.Players.LocalPlayer game.UserInputService.InputBegan:Connect(function(Input, IsTyping) if IsTyping then return end if Input.KeyCode == Enum.KeyCode.C then game.ReplicatedStorage.RemoteEvent:FireServer() end end)
Hope this helped
Best of luck dev!