Hallo,

I'm a beginner. I try to scripting the parts of the tutorial. In this tutorial they say write the following:

-- Destroys whatever touches the parent
-- Variable setup
local trap = script.Parent
 
-- Gets an object to destroy
local function onTouch(objectTouched)
	-- Destroy objectTouched
	print("Something touched the trap part")
	objectTouched:Destroy()
End
 
-- Connects onTouch() to Touched event
trap.Touched:Connect(onTouch)

I write it manual and I used copy/paste. In both cases get an Null-Pointer-Exception.

What is the problem? It is the Version of my Studio?

I hope anybody can help.

P.S.: I'm sorry about my bad english. I try to do it better next time.

2 comments

0

Do you put the script in a part?

0

Yes. The script is Child of a Part. If my Avatar touched the Part, then the Message comes to the console, but my Avatar doesn't destroy.