okay so here’s a few things wrong with your script;
so in the very 1st of the script you create a variable named “Meditation” and used Instance.new to create a bool value? but in this line here you checked if a BoolValue is equal to true?
i think you were trying to write; BoolValue.Value == true maybe? but yet i dont understand it’s use since its value nor the medation variable is even being changed.
also inside the MouseEnter event you decied to put this while loop inside of it? okay so the issue with this is that even while the gui is disabled, the loop will still run, so why dont run the loop while only the GUIS.Enabled is equal to true so instaid you should have while GUIS.Enabled do since the event will still stop when the gui is enabled property is set to false.
a StarterPack localScript? i mean you can probably use BindableEvent to communicate from client to client maybe?
you want it to be toggleabe? well you can use Variables to make it toggleable for example (im gonna use a keybind toggle script cuase of yeah):
note: this is a “EXAMPLE” script so please dont copy and paste it since i kinda speeded trought it -.-
local UIS = game:GetService("UserInputService")
local Toggle = false -- defualt to false
UIS.InputBegan:Connect(function(obj)
if obj.KeyCode == Enum.KeyCode.E then
Toggle = not Toggle --makes it the oppsite of what it currently is (making the toggling effect)
if Toggle then
print("IS ON")
else
print("Is Off")
end
end
end
end)
my question is, are you still gonna wait to use the MouseEnter and MouseLeave event to
also work with the tool AND the users input? if you wanna do that i recomend you put these into functions like this:
note: again this is an example i dont think you should be copy and pasting this cuase uh all it does
is print :3
local GUIS = script.Parent
local function UpdateMaditateGui(Bool)
if Bool then
print("do madeitaiont loop")
else
print("stop ")
end
end
so you can just fire The function to toggle the maditation. i mean if your gonna use multple ways to toggle it?
The usage of the Meditation boolean was to disable my combat (which is in another place, as I have a place where I test very experimental builds/scripts) I didn’t want combat to be activated during the time of meditation so that meditation Bool is tossed for a later use.
Thank you so much for pointing out the loop still running even if the GUI was disabled, that would’ve probably caused some memory issues/lag.
I just plan to toggle it once, via the M key, and then close it out if the player fails the meditation prompt. I also do need the mouse to track if the mouse is on the moving ball.
I tried researching BindableEvents, but feel stumped what I would be putting in the server script mid-way, and if it is the script in the current local gui, then what would be in the LocalScript on the other end since the main function isn’t in the gui anymore.