Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Am I scripting local functions and events correctly in this script?

Asked by 9 years ago

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.

01l--Player--
02local Player = game.Players.LocalPlayer
03local character = Player.Character
04if not character or not character.Parent then
05    character = Player.CharacterAdded:wait()
06end
07 
08--Services/Other--
09local mouse = game.Players.LocalPlayer:GetMouse()
10 
11--Variables--
12local Head = character["Head"]
13local LeftArm = character["Left Arm"]
14local LeftLeg = character["Left Leg"]
15local RightArm = character["Right Arm"]
View all 70 lines...

If more code is needed, just ask!

0
Just one question. Is anywhere in the script, are you defining 'running'? Nickoakz 231 — 9y
0
Mhm, I posted the full script just now. Strykebyte 45 — 9y
0
You should call the function, when he starts running xuefei123 214 — 9y
0
I will try that, thank you Strykebyte 45 — 9y
0
What exactly would that look like? Strykebyte 45 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

Well if you make the script wait 99999999999999999999999999999999999999999 until it's allowed to check if running == false then you're gonna have to wait 99999999999999999999999999999999999999999 seconds before it prints anything too!

1repeat wait(99999999999999999999999999999999999999999) until running == false
2--If you're just yielding until running == false you should drop that timer to something smaller...

Also, you can have KeyUp events to turn running off instead of waiting for disconnect events, it's how I do my own sprinting systems.

0
Yea, the "until running == false" part of your repeat loop will NOT be checked until the massive wait is over, Just do repeat wait() until running == false, it will still stop the script until running has stopped alphawolvess 1784 — 9y
0
Oh wow! You guys are really helpful! Thanks! :D Strykebyte 45 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago
01local function brightUp()
02    if running == true then
03        game.Lighting.Brightness = 2
04        if running == false then
05            game.Lighting.Brightness = 1
06        end
07    end
08end
09 
10brightUp()
0
It didn't work, but thank you for attempting to help. Strykebyte 45 — 9y

Answer this question