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)
You're not defining what 'yourRemoteEvent' really is. It's just... a nil variable. To fix your problem your going to need to set a variable to the remoteevent before actually calling on it.