There was a bunch of other messages between last reply whilst I was typing. Edited now.
Its just an test if the script is even running. Just do it.
I donât want to have a script running every milisecond because it lags my game thats the whole point for this script
That is always running tho, i only want to run mine whenever the gui is enabled
It works for others and me, but apparently not you.
Perhaps you can add more detail such as showing the explorer or a video of you running it?
We donât really know whatâs in your place
while task.wait() do
If Script.Parent.Enabled then
--code
end
end
Iâm gonna guess that the snippet of code youâve given us isnât your entire script. What is probably happening is that the code above the snippet is stopping the snippet from running - do you happen to have another while do
loop somewhere in there?
If you ever use a while do
loop in a script, I would highly recommend wrapping it in a coroutine using the task library. Hereâs an example with the snippet youâve given us:
task.spawn(function()
while script.Parent.Enabled == true do
wait()
print("Gui is enabled")
end
end)
Where are you enabling it - in Ur players plrgui or startergui
I dont wanna use while true do or task.wait it lags my game
Im enabling it in the players gui
No, thats my whole script and it isnât working. Also i donât want the code to always be running which is your task.wait because it lags my game
I think @MrSmartyPants126 has already suggested the best idea for your use case. Using a changed event.
script.Parent:GetPropertyChangedSignal("Enabled"):Connect(function()
-- your code
end)
THANKS, i will try this as soon as i get on my pc and ill let u know if it worked
is the script server script or local script
the script is a local script - minimum character limit -
yeah I would also do
while true do
if script.Parent.Enabled == true then
print("Enabled")
end
end
you could also use render stepped if its in a local script
see i made this post because i dont want to use while true do because it lags but i found my solution
Why does task.wait() lag your computer, thatâs a massive problem as itâs just basically required for scripting certain things
no, it lags my game, my pc can run it, its just if i have lots of task.Waits() itâll lag
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.