So I'm trying to add a shift to sprint script but it keeps stopping after a few seconds so I tried this to maybe fix it but now im getting this
game:GetService("UserInputService").InputBegan:Connect(function(input) -- Input Began checks if the play presses anything and fires whenever the player does so
if input.KeyCode == Enum.KeyCode.LeftShift then -- Detects LS press
-- Fire a remote event
yourRemoteEvent:FireServer()
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(input)
--Send another remote event to stop Bool Value when enabled
end)
This is also my sprint script in case it can be fixed in there instead
-- Define Vars
local player = game.Players.LocalPlayer
local Character = player.Character
local UserInputService = game:GetService("UserInputService")
local Speed = 25
-- Script
UserInputService.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = Speed
-- Do This Scrpt
end
end)
UserInputService.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16
end
end)

3 comments
Thanks I ended up going with a different sprint script because I wanted it to take away stamina also but now im getting this error attempt to index local 'data' (a number value)
this is the full script its from local RE = game:GetService("ReplicatedStorage"):WaitForChild("RE") RE.OnServerEvent:connect(function(player, request, data) if request == "sprint" then player.Character.Humanoid.WalkSpeed = data(1) end end)
your 2nd argument on the client side needs to be data and not a nil value