Hello, me and a friend are trying to make a tycoon from scratch to get practice scripting and the part where he brick goes to get destroyed is not happening for some reason. We tried making it print “h” when it hits but it does not do that, so I think that the event is not going off for some reason. We do not know why, and have tried many things to fix it. The script was working earlier but then we made a new model and copy and pasted the script and now it does not work.
destroying = script.Parent
givemoney = game.ServerStorage.moneytogive
destroying.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid == nil then
hit:destroy()
givemoney.Name = "moneytogive"
givemoney.Value = givemoney.Value + 5
end
end)
Is this your whole script? If it is you’ve never actually defined what ‘destroying’ is, unless you define it the script has no idea what you’re talking about. You need to add another line at the beginning of the script that defines what destroying is. Ex:
destroying = game.Workspace.Part -- This is just an example