So in my game there is an inventory system and a running system. The problem I'm having with this is that when I open the inventory I can reset my speed. I tried to fix it but now when I exit the inventory I can't move at all.
This is my script.
local Mouse = game.Players.LocalPlayer:GetMouse() local RunGUI = script.Parent.RunGUI.RunText RunGUI.BackgroundColor3 = Color3.new(.100,.100,.100) InInventory = false Mouse.KeyDown:Connect(function(key) if key:lower() == "0" or key:upper() == "0" then if InInventory == false then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = game.Players.LocalPlayer.Character.Humanoid.WalkSpeed * 1.35 RunGUI.BackgroundColor3 = Color3.new(.0,.3,.7) end end end) Mouse.KeyUp:Connect(function(key) if key:lower() == "0" or key:upper() == "0" then if InInventory == false then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 -- [+ (any future Gamepasses or something like that)] RunGUI.BackgroundColor3 = Color3.new(.100,.100,.100) end end end) Mouse.KeyDown:Connect(function(key2) if key2:lower() == "e" or key2:upper() == "E" then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 InInventory = true end end) Mouse.KeyDown:Connect(function(input) if input:lower() == "e" or input:upper() == "E" then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 end end)
The inventory script is somewhere else but it has nothing to do with running and couldn't affect the run script.
If anyone knows how to fix this, please help.