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

Why isn't it exploding?? please help! i've tried everything!!

so i have a cat game called "Eaten By Cats!" by SethPaw, and I want there to be a mechanic where if you are already a poop and you get eaten again, the cat's mouth explodes. the mechanic i am done with is the poo mechanic, where you turn into poo when digested by the cat. but I cant quite get the explosion mechanic working. what happens is... nothing. i can get eaten and become a poo, but sadly the explosion thing doesn't do anything, poo mesh or not.

function onHit(hit) if (hit.Parent.Head.Balloon:FindFirstChild("Mesh")~=nil) then local exp = Instance.new("Explosion") exp.Position = script.Parent.Position end end

script.Parent.Touched:connect(onHit)

What's the problem!!?? link to the unfinished game: https://www.roblox.com/games/735444651/Eaten-By-Cats

1 answer

✓ Accepted answer

I did some tidying First of all You didn't put in exp.Parent That is important Or else the instancewould be nil

local debounce = false
function onHit(hit) 
	if hit.Parent.Head.Balloon:FindFirstChild("Mesh")  and debounce == false then  	
		debounce = true	
		local exp = Instance.new("Explosion")
		exp.Position = script.Parent.Position 
                exp.Parent = hit.Parent.Torso -- You didn't set the parent of the Instance
		else
			print("Hit.Parent.Head.Ballon.Mesh is nil")
	end
	wait()
	if debounce == true then
		debounce = false
	end 
end

script.Parent.Touched:Connect(onHit)

Please submit this answer if it worked!

1 comment

0

Setting parent then properties slows down game time - set properties then parent. Also put it directly into workspace.

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