This script is a local script thats inside a local script thats inside a gui. The script is testing if you have a sword if its true then it will disable the shop script so it you can't buy it twice.
while true do wait(0.01) if game.Players.LocalPlayer.BackPack.LongSword == nil or game.Players.LocalPlayer.Character.LongSword == nil then script.Parent.Disabled = true script.Parent.Parent.Text = "Own" end end
Children are not nil
. If a child doesn't exist and you try to access it, ROBLOX will throw an error.
Use :FindFirstChild("ObjName")
instead, which will return nil
when the object doesn't exist.
wait
will wait for at least a 30th of a second, you might as well use wait(0)
or wait()
if you intend as quickly as possible.
I'm not sure why you would use or
in this particular case. Unless the player has two copies of the sword, one wielded and one not, the condition will always be true
.