Is there a way to change the changed signal to an if statement?
Absolutely, just listen to the prompt shown and prompt hidden events
You would check the Magnitude with an if
statement.
There are many ways of approaching this. I highly recommend utilizing Roblox events instead of yielding threads. Your current solution is as bad on performance as you may think.
My suggested method is having a part that indicates the area that the player can call openGUIFunction. Use a touched event to check when the player touches this part. If you need help implementing this, let me know.
Hello, do you mind whipping up a script as I’ve tested with that but have found that the event doesn’t fire.
Perfect, thankyou! I’ll try that.
Make sure that the requires line of sight option is dissabled, might give you some problems
Humanoid:GetPropertyChangedSignal("Magnitude"):Connect(function()
if (humanoidRootPart.Position - part.Position).Magnitude <= 10 then
--do something
end
end)
Ok, great, thankyou to all of you who have helped and replied with some great solutions. I will try all of them and if they don’t work I’ll reply to this. Thankyou so much! Cheers!
– Creative Side-B
Incredible! Thankyou so much! You’ve been a great help!
ipair loops is not very performance efficient from what i have heard
pair loops is much better than ipair loops
numeric loop is faster than pair loops BUT-!
(i did NOT test for this, but i looked up some where on the internet and found this information (even tho i didnt want to)
you can read into it yourself if you want)
!-numeric loops looks less clean (clean to me, means that the script is very logically easy to understand)
unless you need the performance out of the numeric loop, you’d use it
but if not i suggest you to use a pair loop instead
this is how you use it
local table = {}
for index = 1, #table do
local value = table[index]
--do whatever you want with value. its pretty much the same thing in a pair and ipair loop
end
run service fires every frame
unless the player is running on a toaster at 20fps
it might actually be worst for frame rate as most people runs at 60fps
Ok, thankyou, is heartbeat any different?
heartbeat also fires every frame
but it fires at the END of a frame
Yea! I always use it because it lets me run the other events underneath the loop, so it’s amazing for me.