So I have a LocalScript in the starter pack. And its child is a sound, named sound. In Roblox Studio, line 6 gets underlined in blue. I have no idea what's wrong with it. Help?
local k = game.Players.LocalPlayer.Name local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key:byte() == 32 and game.Workspace[k].Humanoid.JumpPower == 125 then script.Sound:Play() game.Workspace[k].Humanoid.JumpPower = 0 script.Disabled = true end end)
There isn't any problem that would affect your script. It's just a warning to make cleaner code, saying that if you are going to span an if statement across multiple lines, indent the lines for better readability.
-- gives warning if key:byte() == 32 and game.Workspace[k].Humanoid.JumpPower == 125 then -- does not give warning if key:byte() == 32 and game.Workspace[k].Humanoid.JumpPower == 125 then
Hope this helps :)
KeyDown
to detect user input. It is very inconsistent and deprecated. Switch to UserInputService
. connect
is also deprecated. Also, your script will error if a player named Part joins the game LOL.local plr = game:GetService("Players").LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(key, chatting) if chatting then return end if key.KeyCode == Enum.KeyCode.F and char.Humanoid.JumpPower == 125 then script.Sound:Play() char.Humanoid.JumpPower = 0 script.Disabled = true end end)