Heres my attempt it works but it also no longer lets the walk keys work.
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local function SlowWalk()
print("InitializeSlowWalk")
character.Humanoid.WalkSpeed = 0
end
local function NormalWalk()
print("InitializeNormalWalk")
character.Humanoid.WalkSpeed = 16
end
contextActionService:BindAction("SlowWalkSpeed", SlowWalk, false, "s")
contextActionService:BindAction("NormalWalkSpeed", NormalWalk, false, "w")
You’re binding the action, therefore, you’re overwriting the purpose of S and W, which are allowing the player to walk in their respective direction. Instead, use UserInputService.InputBegan:
game:GetService("UserInputService").InputBegan:Connect(function(input)
local key = input.KeyCode
if key == Enum.KeyCode.W then
NormalWalk()
elseif key == Enum.KeyCode.S then
SlowWalk()
end
end)
how can I call a function from earlier in the script?
I know how to connect a new function
if key == move_Forward and not gameProccessedEvent then
print("W")
character.Humanoid.WalkSpeed = 12
elseif key == move_Backward and not gameProccessedEvent then
print("S")
character.Humanoid.WalkSpeed = 6
end
end
userInputService.InputBegan:Connect(walk_())
but I want to call walk_() but I dont know the correct syntax.