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
while true do if script.Parent.V.Value == 1 and Light.Value == 1 then script.Parent.Base.PointLight2.Range = 18 script.Parent.Humanoid.WalkSpeed = 30 end
Second one
while true do wait(1) script.Parent.HumanoidRootPart.Steps:Stop() script.Parent.Base.PointLight.Range = 0 script.Parent.Base.PointLight2.Range = 0 script.Parent.Humanoid.WalkSpeed = 6 script.Parent.V.Value = 1 local Player = game:GetService("Players").LocalPlayer local stats = Player:WaitForChild("leaderstats") local Light = Player.leaderstats.Light if script.Parent.V.Value == 1 and Light.Value == 1 then script.Parent.Base.PointLight2.Range = 18 script.Parent.Humanoid.WalkSpeed = 30 else end wait(math.random(7 ,10)) script.Parent.V.Value = 0 script.Parent.Base.PointLight.Range = 18 script.Parent.Humanoid.WalkSpeed = 25 wait (1) if Light.Value == 1 then script.Parent.Humanoid.WalkSpeed = 6 script.Parent.HumanoidRootPart.Anchored = true script.Parent.HumanoidRootPart.Scream:Play() script.Parent.HumanoidRootPart.Steps:Stop() wait (2) script.Parent.HumanoidRootPart.Steps:Stop() script.Parent.HumanoidRootPart.Scream:Stop() script.Parent.Base.PointLight.Range = 0 script.Parent.Base.PointLight2.Range = 0 wait (3) script.Parent.HumanoidRootPart.Anchored = false script.Parent.Humanoid.WalkSpeed = 6 script.Parent.V.Value = 1 wait (3) end end
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:
local pause = false spawn(function() while true do if script.Parent.V.Value == 1 and Light.Value == 1 then script.Parent.Base.PointLight2.Range = 18 script.Parent.Humanoid.WalkSpeed = 30 pause = true --Pauses the loop else pause = false --Resumes the loop. end end end) while true do wait(1) if not pause then script.Parent.HumanoidRootPart.Steps:Stop() script.Parent.Base.PointLight.Range = 0 script.Parent.Base.PointLight2.Range = 0 script.Parent.Humanoid.WalkSpeed = 6 script.Parent.V.Value = 1 local Player = game:GetService("Players").LocalPlayer local stats = Player:WaitForChild("leaderstats") local Light = Player.leaderstats.Light if script.Parent.V.Value == 1 and Light.Value == 1 then script.Parent.Base.PointLight2.Range = 18 script.Parent.Humanoid.WalkSpeed = 30 end wait(math.random(7 ,10)) script.Parent.V.Value = 0 script.Parent.Base.PointLight.Range = 18 script.Parent.Humanoid.WalkSpeed = 25 wait (1) if Light.Value == 1 then script.Parent.Humanoid.WalkSpeed = 6 script.Parent.HumanoidRootPart.Anchored = true script.Parent.HumanoidRootPart.Scream:Play() script.Parent.HumanoidRootPart.Steps:Stop() wait (2) script.Parent.HumanoidRootPart.Steps:Stop() script.Parent.HumanoidRootPart.Scream:Stop() script.Parent.Base.PointLight.Range = 0 script.Parent.Base.PointLight2.Range = 0 wait (3) script.Parent.HumanoidRootPart.Anchored = false script.Parent.Humanoid.WalkSpeed = 6 script.Parent.V.Value = 1 wait (3) end end end
EDIT: I forgot that return would stop it. I added an if statement to check when it loops.