I am new to Roblox scripting (Lua apparently) and was fiddling with a function that is called when one Part (dubbed the "Sender") is touched by another Part, which is actually a tool with a Part called "Handle" inside of it, and a third Part nested inside that. I have also added an IntValue to the latter to be read upon touching.
The object tree looks like this:
__Apple (Tool) L_Handle (Part) L_TouchInterest L_Value (IntValue) L_Apple (Part) L_Handle-to-Part Strong Joint
The function is called alright, and the part with the name "Handle" is correctly identified, but I cannot for the world get a hold of the IntValue using the following code:
function onTouch(hit) print("Sender touched by "..hit.Name) local val = hit:FindFirstChild("IntValue", true) if val == not nil then print("Found IntValue: "..val.Name) if val.Name == "Cash" then --Get Money For Apple print("Players: "..game.Players.LocalPlayer.Name) game.Players.LocalPlayer.leaderstats.Money.value = game.Players.LocalPlayer.leaderstats.Money.value + val.value end else print("IntValue Not Found!") end hit:Destroy() end script.Parent.Touched:connect(onTouch)
In other words: It keeps on logging "IntValue Not Found"! I have changed the name of the IntValue to "Value" and back to "IntValue" to no avail. I have been adding clones of it to several different layers of the composite object, but no results.
Any help is greatly appreciated!
BTW The object is a Tool, because the player is supposed to be able to pick it up and place it on the "Sender".