Hello again:3, I am still confused with this Universal grasping loop, I think I've got it, but I have another issue. It's grasping the wrong Object, even though there are strict requirements in place, I believe it is a syntaxing error that I've made, but I can't seem to wrap my head around it as I have too many other issues I'm focusing on, also, I suck at making Universal Scripts, I'm all direct or dynamic.

As I've explained before, this loops job is to find out whether or not your cursor is overtopping an item, this item must have an ItemTag; boolean - in order to be counted as an item, It keeps thinking the character's leg or sky is an `item' or maybe it's something I've done wrong, most likely the second option;), here's the script

local localPlayer = game:GetService("Players").LocalPlayer
local cursor = localPlayer:GetMouse(); local cursorPoint = cursor.Target
local item_
while (cursorPoint ~= item_) do
	print("Ran")
	cursorPoint = cursor.Target
	pcall(function()
		if cursorPoint:IsA("BasePart") then --//Set to 'Tool'.
			print(cursorPoint)
			for _, descendant in ipairs(cursorPoint:GetDescendants()) do
				if findObject(descendant, "BoolValue", "ItemTag") then print("foundItem")
					item_ = cursorPoint.Name
					cursorPoint = item_
				end
			end
		end
	end)
	wait(.5)
end

print("Item Checked.") --// Just to let me know if the loop actually broke, in this case, did.

A variable is supposed to index the item, but since it's not actually an Item, it keeps giving me Argument 1 missing or nil

local item = workspace:WaitForChild(item_)

Could someone help me fix this, also potentially find a patch to make sure it doesn't break for touching the sky or character or chatGui? - also happens.

Thanks!

8 comments

0

Where is the issue in the code you sent?

0

"A variable is supposed to index the item, but since it's not actually an Item, it keeps giving me 'Argument 1 missing or nil' ; 1 local item = workspace:WaitForChild(item_)"

0

The loop is the real issue, the variable keeps getting false information provided by the loop

0

Second paragraph at the top you'll find my explanation

0

Check if Mouse.Target is nil?

0

Ignore 'Set to Tool', it's a reminder to me once I've got the whole thing done

0

Mouse.Target is nil

0

Because of mal provided information by the loop,