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

How can i put together that two scripts?

Asked by 6 years ago

I have that two scripts: And ,if its possible, i want to "pause" the second one when the first one detects both values ==1

First one

1while true do
2if script.Parent.V.Value == 1 and Light.Value == 1 then
3    script.Parent.Base.PointLight2.Range = 18
4    script.Parent.Humanoid.WalkSpeed = 30
5 
6end

Second one

01while true do
02wait(1)
03script.Parent.HumanoidRootPart.Steps:Stop()
04script.Parent.Base.PointLight.Range = 0
05script.Parent.Base.PointLight2.Range = 0
06script.Parent.Humanoid.WalkSpeed = 6
07script.Parent.V.Value = 1
08local Player = game:GetService("Players").LocalPlayer
09local stats = Player:WaitForChild("leaderstats")
10local Light = Player.leaderstats.Light
11if script.Parent.V.Value == 1 and Light.Value == 1 then
12    script.Parent.Base.PointLight2.Range = 18
13    script.Parent.Humanoid.WalkSpeed = 30
14else
15 
View all 39 lines...

1 answer

Log in to vote
1
Answered by
popeeyy 493 Moderation Voter
6 years ago
Edited 6 years ago

Yes, you are able to put them into one script using the spawn function. Here's more info on it. http://robloxdev.com/articles/Thread-Scheduler Here's how I would do it:

01local pause = false
02 
03spawn(function()
04    while true do
05        if script.Parent.V.Value == 1 and Light.Value == 1 then
06                script.Parent.Base.PointLight2.Range = 18
07                script.Parent.Humanoid.WalkSpeed = 30
08            pause = true --Pauses the loop
09        else
10            pause = false --Resumes the loop.
11        end
12    end
13end)
14 
15while true do
View all 52 lines...

EDIT: I forgot that return would stop it. I added an if statement to check when it loops.

0
i like this. User#19524 175 — 6y
0
You can also make the while loop `while not pause do` instead of having constant return statements? T0XN 276 — 6y
0
I tested that out, and when I changed the value and put it back, it didn't loop anymore. popeeyy 493 — 6y
0
Your loop resumes despite using a return statement? saenae 318 — 6y
Ad

Answer this question