Am I scripting local functions and events correctly in this script?
I started scripting around two months ago and decided to start branching out. For my first task, I decided to make a run button, and when the player runs, the game's brightness would increase, however, I need help, as it is not working and no errors are appearing in the output.
02 | local Player = game.Players.LocalPlayer |
03 | local character = Player.Character |
04 | if not character or not character.Parent then |
05 | character = Player.CharacterAdded:wait() |
09 | local mouse = game.Players.LocalPlayer:GetMouse() |
12 | local Head = character [ "Head" ] |
13 | local LeftArm = character [ "Left Arm" ] |
14 | local LeftLeg = character [ "Left Leg" ] |
15 | local RightArm = character [ "Right Arm" ] |
16 | local RightLeg = character [ "Right Leg" ] |
17 | local Torso = character.Torso |
21 | for _, kid in ipairs (script.Parent:GetChildren()) do |
22 | if kid.className = = "Tool" then return kid end |
27 | mouse.KeyDown:connect( function (key) |
28 | key = string.lower(key) |
29 | if string.byte(key) = = 107 then |
31 | local keyConnection = mouse.KeyUp:connect( function (key) |
32 | if string.byte(key) = = 108 then |
37 | game.Workspace.CurrentCamera.FieldOfView = ( 70 +(i* 2 )) |
40 | game:GetService( "Chat" ):Chat(Head, "Clock Up..." , Enum.ChatColor.Red) |
41 | game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 150 |
42 | game.Players.LocalPlayer.Character.Humanoid.JumpPower = 65 |
43 | LeftLeg.BottomSurface = "Glue" |
44 | RightLeg.BottomSurface = "Glue" |
45 | repeat wait( 99999999999999999999999999999999999999999 ) until running = = false |
46 | keyConnection:disconnect() |
47 | game:GetService( "Chat" ):Chat(Head, "Clock Over..." , Enum.ChatColor.Red) |
48 | game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 |
49 | game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50 |
50 | LeftLeg.BottomSurface = "Smooth" |
51 | RightLeg.BottomSurface = "Smooth" |
53 | game.Workspace.CurrentCamera.FieldOfView = ( 80 -(i* 2 )) |
62 | if running = = true then |
63 | game.Lighting.Brightness = 2 |
64 | if running = = false then |
65 | game.Lighting.Brightness = 1 |
70 | game.Lighting.LightingChanged:connect(brightUp) |
If more code is needed, just ask!