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

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

Asked by 6 years ago

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

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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!

0
Setting parent then properties slows down game time - set properties then parent. Also put it directly into workspace. Thundermaker300 554 — 6y
Ad

Answer this question