Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Pls help me with this? I will really be thankful!

**So the issue i am getting here is : ** Workspace.TycoonModel.MainItems.ConveyorBelt.CollectorPart.Script:5: attempt to perform arithmetic (add) on nil and number

and this is the code which i have typed:

local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue

script.parent.Touched:Connect(function(Hit) if Hit.Name == "Part" and Hit:FindFirstChild("CashValue") then CashValue.Value += Hit:FindFirstChild("CashValue").Value Hit:Destroy() end end)

What I am trying to do is to destroy a part which is dropped by the dropper that touches the white shining plate and the end of the conveyor belt, and add cash into the cashvalue.

I will really, REALLY appreaciate all help!

ThankYOU!!

2 comments

0

Change script.parent to script.Parent because .parent with small "p" won't work and will error.

0

Im assuming the value property of CashValue is returning nil. Make sure that the CashValue Instance is a integer value, number value, etc. and not something like an object value.

1 answer

i tryed my best

local CashValue = script.Parent.Parent.Parent.Parent.Values.CashValue

script.Parent.Touched:Connect(function(Hit) 
if Hit.Name == "Part" and Hit:FindFirstChild("CashValue") then 
CashValue.Value += Hit:FindFirstChild("CashValue").Value 
Hit:Destroy() 
end 
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.