Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by 1 year ago

**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!!

0
Change `script.parent` to `script.Parent` because .parent with small "p" won't work and will error. T3_MasterGamer 2189 — 1y
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. JustinWe12 723 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

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)
Ad

Answer this question