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

ontouch or touch invalid?

Asked by
korj5 0
10 years ago
local brick = game.Workspace      --the part that u wnt to have explode when touched

brick.Touched:connect(function(hit)
    if hit.Parent and hit.Parent.Humanoid then
        humanoid = hit.Parent.Humanoid
        explode = Instance.new("Explosion", brick)
end)

1 answer

Log in to vote
1
Answered by 10 years ago
function ont (hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid") 
    if humanoid then
        local e = Instance.new("Explosion")
        e.Parent = script.Parent
        e.Position = script.Parent.Position
    end
end

script.Parent.Touched:connect(ont)

There you go, that should work!

0
Reason for error: Your local brick is the whole workspace, if you wanted to do the whole workspace then you would need to do game.Workspace:GetChildren() <-- using that to replace the bricj - game.Workspace you also need a position for the explosion. wattleman 90 — 10y
0
Thanks!! korj5 0 — 10y
0
You should also keep the `hit.Parent` check! BlueTaslem 18071 — 10y
Ad

Answer this question