so yeah, instead of running when i enter, and running the other half of the script when exiting
it just runs the first half in both circumstances
heres the script
local DustAtmos = game.ReplicatedStorage.Dusty.DustAtmosphere:Clone()
local DustSky = game.ReplicatedStorage.Dusty.OrangeSky:Clone()
local ClearAtmos = game.ReplicatedStorage.ClearAtmosphere:Clone()
local ClearSky = game.ReplicatedStorage.ClearSky:Clone()
local DustSpace = game.Workspace.DustStormAtmos
local Debounce1 = true;
local Debounce2 = true;
DustSpace.Touched:Connect(function()
if (Debounce1) then
Debounce1 = false;
DustAtmos.Parent = game.Lighting
DustSky.Parent = game.Lighting
print('Player entered the DustStorm Region')
wait(2);
Debounce1 = true;
end
end);
DustSpace.Touched:Connect(function()
if (Debounce2) then
Debounce2 = false;
if ((DustSpace.Position + DustSpace.CFrame.lookVector * 3) - Hit.Parent.HumanoidRootPart.Position).Magnitude <= 3 then
ClearSky.Parent = game.Lighting
ClearAtmos.Parent = game.Lighting
print('Player has exited the DustStorm Region')
wait(2);
Debounce2 = true;
end
end
end);
So, it never got to print, player has exited the dustregion, instead it executes the first script half when:
Entering (like it should) but also when exiting (like it shouldnt)
oh and the second part like doesnt work at all (is supposed to run when exitting)
You’re connecting two different functions to the same event, I think instead of Touched you meant TouchEnded, since that corresponds to leaving the zone.
Also for zones I don’t recommend using parts, instead I recommend using a module like Zone+, as it is more reliable and efficient.
No, because you want the first one to trigger when you enter the zone, the first one should be Touched.
Since you want the second one to trigger when you exit the zone, the second one should be TouchEnded.
Again, I seriously recommend you use a module instead of parts, so that you can define your zones more precisely and without having to deal with roblox’s weird collision detection.
well it did help, but after exitting the part, it no longer does the script thing, instead it only works once and no longer executes any command, as if it was not looped, how should i loop it?
despite that, the ClearSky/ClearAtmos always stack up alot in game.Lightning, and how can i make it so ClearSky/ClearAtmos are in there since the beginning without causing a duplicate when the script is executed, and make the first half Destroy ClearSky/Atmos without getting the script to not run because there is nothing atm
This script will only work when it is inserted in the part.
If you want it to work inside the part, make sure you use Script.Parent, or it will work wherever it is.
local DustAtmos = game.ReplicatedStorage.Dusty.DustAtmosphere:Clone()
local DustSky = game.ReplicatedStorage.Dusty.OrangeSky:Clone()
local ClearAtmos = game.ReplicatedStorage.ClearAtmosphere:Clone()
local ClearSky = game.ReplicatedStorage.ClearSky:Clone()
local DustSpace = script.Parent --What Script.Parent does is it will run the function below only when it is inside the part game.Workspace.DustStormAtmos. The script looks for that specific part while Script.Parent looks for the thing that the script is inside of.
local Debounce1 = true;
local Debounce2 = true;
DustSpace.Touched:Connect(function()
if (Debounce1) then
Debounce1 = false;
DustAtmos.Parent = game.Lighting
DustSky.Parent = game.Lighting
print('Player entered the DustStorm Region')
wait(2);
Debounce1 = true;
end
end);
DustSpace.Touched:Connect(function()
if (Debounce2) then
Debounce2 = false;
if ((DustSpace.Position + DustSpace.CFrame.lookVector * 3) - Hit.Parent.HumanoidRootPart.Position).Magnitude <= 3 then
ClearSky.Parent = game.Lighting
ClearAtmos.Parent = game.Lighting
print('Player has exited the DustStorm Region')
wait(2);
Debounce2 = true;
end
end
end);
Hope this works. If it doesn’t, you know where to find me!
the script is inside Playerbackpack, it does do things, but i need it to be local, its a local script, if its not a local script it owuld change it for everyone therefore if yours is not intended to be local then its obsolete sorry
ye, when i jump while inside it also detects me as being outside, ima check out modules and just learn how to use it, my game is going to have multiple parts where that would be useful, for example the fact that its post apocalyptic, multi-weather and multi-environmental. Thx bro
do you know how to set that part as a Zone+?, cause its my first time hearing of it, i heard that it also uses or can use parts or Region3, how do i set Region 3’s and how to use parts/Region3 for Zone+
and how to get Region3?