The following code checks ever 0.5 seconds to see if the SelectedSlot has a Y position of 0, 0. If it does, then all tools currently equipped by the player will be unequipped.
However this crashes my game. I have a feeling that this while loop is the reason.
while true do
if SelectedSlot ~= nil then
ScaleX = SelectedSlot.Position.X.Scale
OffsetX = SelectedSlot.Position.X.Offset
ScaleY = SelectedSlot.Position.Y.Scale
OffsetY = SelectedSlot.Position.Y.Offset
if OffsetY == 0 then
Player.Character.Humanoid:UnequipTools()
end
wait(0.5)
end
end
Any solutions to make this loop work or alternatives that will serve the same purpose? Thanks in advance.

3 comments
its not really a good idea to rely on the gui position to run code, you should do this upon the users action / event.
You should use :GetPropertyChangedSignal (http://wiki.roblox.com/index.php?title=API:Class/Instance/GetPropertyChangedSignal) instead. Also, the reason it's freezing is you only wait if the condition is true. You should move the wait outside of the if statement.
idk WaitForChild() since it yields