Error: 14:14:51.507 Players.CMB1048.PlayerScripts.LocalScript:22: Expected 'end' (to close 'then' at line 13), got <eof>; did you forget to close 'then' at line 18? - Studio - LocalScript:22 btw sorry i had to repeat this
UserInputService = game:GetService("UserInputService") local players = game.Players.LocalPlayer local UserInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() UserInputService.InputBegan:Connect(function(input,gameProcessed) --if not gameProcessed then if input.KeyCode == Enum.KeyCode.LeftShift then if players:FindFirstChild("Humanoid") then players.Humanoid.CharacterWalkSpeed = 90 UserInputService.InputEnded:Connect(function(input,gameProcessed) if input.KeyCode == Enum.KeyCode.LeftShift then if players:FindFirstChild("Humanoid") then players.Humanoid.CharacterWalkSpeed = 16 end end end)
Try this
Add a LocalScript to StarterCharacterScripts
Use this code
local userInputService = game:GetService("UserInputService") local humanoid = script.Parent:FindFirstChild("Humanoid") local sprinting = false userInputService.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then if sprinting == false then sprinting = true humanoid.WalkSpeed = 32 else sprinting = false humanoid.WalkSpeed = 16 end end end)
Whenever the error mentions "<eof>", it's because you forgot an end
somewhere (or, in this case, three of them). If you keep up consistent indentation, it makes it easier to find - whenever you have a double-unindent, there's a problem.
Also, you should almost never connect to events inside other events!
local UserInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.LeftShift then humanoid.WalkSpeed = 90 end end) UserInputService.InputEnded:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.LeftShift then humanoid.WalkSpeed = 16 end end)
Modifications:
humanoid
once outside of the events for simplicity (I assume this is a StarterCharacterScript)gameProcessed
(or else when the user is chatting and presses shift
or other controls you'll process them instead of correctly ignoring them)WalkSpeed
not CharacterWalkSpeed