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

What is wrong with my explosion script?

Asked by 9 years ago

I have a brick and it has text above it, and i made this script so it counts down then the text changes and says different stuff but the explosion wont work at the end. It says "Position is not a valid member of Model" and the brick wont remove as i put in the command at the bottom. Please help.

x=script.Parent

 for i=10,0, -1 do
wait(1)
x.Name=(i)
if i==0 then x.Name="BOOM!"
    wait(2.2)
    x.Name="Haha"
    wait(1.2)
    x.Name="just kidding"
    wait(0.9)
    x.Name="But, seriously"
    wait(0.5)
    x.Name="BOOM!"
    wait(0.001)
    local e = Instance.new("Explosion")
    e.Position = x.Position
    e.Parent = game.Workspace
    e.BlastPressure = 100000
    e.BlastRadius = 120
    x:remove()

end
end

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

It doesn't make sense to use if i == 0 in this case. If you mean after the countdown, then just put it *after the for loop:

x = script.Parent

for i=10,0, -1 do
    wait(1)
    x.Name = i
end

wait(2.2)
x.Name = "Haha"
wait(1.2)
x.Name = "just kidding"
wait(0.9)
x.Name = "But, seriously"
wait(0.5)
x.Name = "BOOM!"
wait(0.001)
local e = Instance.new("Explosion")
e.Position = x.Position
e.Parent = game.Workspace
e.BlastPressure = 100000
e.BlastRadius = 120
x:Remove()

The error is exactly what it says. x is a Model, but Models don't have a .Position property.

I'm assuming this is a Humanoid, and so x.Head is some part. In that case, you could use x.Head.Position

If for some reason you can't use a part's position, you can use x:GetModelCFrame().p to mean somewhere around the middle of the overall model.

Ad

Answer this question