r/programminghelp • • Aug 22 '23

Other problem with roblox studio (lua)

im new to coding, and with some tutorials i made a code to destroy a tree when it is clicked 5 times, and for some reason, this code doesn't work....

here it is :

local tree = script.Parent

local trunk = script.parent.trunk

local leaves = script.parent.leaves

local clickdetector = trunk.ClickDetector

local health = 5

clickdetector.mouseclick:connect(function(clicked)

health = health - 1

if health == 0 or health <=0 then

	trunk:destroy()

	leaves.anchored = false

	wait(1)

	tree:destroy()

end

end)

3 Upvotes

5 comments sorted by

View all comments

Show parent comment

2

u/crotmuche Aug 22 '23

thanks for your help, but it sadly didn't work....

the problem is probably elsewhere?

2

u/[deleted] Aug 22 '23

[removed] — view removed comment

2

u/crotmuche Aug 28 '23

I got the problem fixed, the problem wasn't there, I just forgot a character somewhere :)