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
1local brick = game.Workspace      --the part that u wnt to have explode when touched
2 
3brick.Touched:connect(function(hit)
4    if hit.Parent and hit.Parent.Humanoid then
5        humanoid = hit.Parent.Humanoid
6        explode = Instance.new("Explosion", brick)
7end)

1 answer

Log in to vote
1
Answered by 10 years ago
01function ont (hit)
02    local humanoid = hit.Parent:FindFirstChild("Humanoid")
03    if humanoid then
04        local e = Instance.new("Explosion")
05        e.Parent = script.Parent
06        e.Position = script.Parent.Position
07    end
08end
09 
10script.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