|
Hi I've mad a new script :
"local Part = script.Parent
function onTouch (Brick)
local Player =
Brick.Parent:findFirstChild("Humanoid")
Player.Health = Player.Health - 100
end
Part.Touched:connect(onTouch)"
but I want it to Explode the player I don't know how to do it.
Please explain how the script you're showing works, Because I'm a beginner at Lua |
|
|
The way your function is set up, it will never explode. Your function needs to create an explosion, which is an actual instance, and they explode as soon as they are in existance. So, instead of making the player's health at 0, try putting this in your function:
Instance.new(Explosion)
If this doesn't work, try explosion in lower-case (not caps)
Hope this helps. |
|
|
I just read the rest of your post(lol) so here is how the script should look like:
local Part = script.Parent
function onTouch(Brick)
Instance.new(Explosion)
end
Part.Touched:connect(onTouch)
(This script basically says to create an explosion when a player touches it) |
|
FriedtjofJoin Date: 2010-07-02 Post Count: 1932 |
Pls no, cool.
local Part = script.Parent
function onTouch(Brick)
local exp = Instance.new(Explosion)
exp.Parent = game.Workspace
exp.Position = Brick.Position
exp.ExplosionType = "NoCraters"
exp.DestroyJointRadiusPercent = 50
exp.BlastRadius = 6
exp.BlastPressure = 500000
end
That sets every property of an explosion. Position and Parent are the only ones you really need, but you can toy with the others.
Lord of all things, breaded and unbreaded. |
|
FriedtjofJoin Date: 2010-07-02 Post Count: 1932 |
Whoops, forgot quotes.
local Part = script.Parent
function onTouch(Brick)
local exp = Instance.new("Explosion")
exp.Parent = game.Workspace
exp.Position = Brick.Position
exp.ExplosionType = "NoCraters"
exp.DestroyJointRadiusPercent = 50
exp.BlastRadius = 6
exp.BlastPressure = 500000
end
Lord of all things, breaded and unbreaded. |
|
|
Thank you Cool and ghost, although both of ur scripts didn't work, so I combined them together in the way I understand and i tworked.
this is the script :
"local Part = script.Parent
function onTouch(Brick)
local Player =
Brick.Parent:findFirstChild("Humanoid")
local E = Instance.new("Explosion")
E.Parent = script.Parent
E.Position = Brick.Position
E.ExplosionType = "NoCraters"
E.DestroyJointRadiusPercent = 50
E.BlastRadius = 6
E.BlastPressure = 500000
Player.Health = Player.Health - 100
end
Part.Touched:connect(onTouch)" |
|
|
QormJoin Date: 2010-07-25 Post Count: 1650 |
script.Parent.Touched:connect(function(onTouch)
if onTouch.Parent:findFirstChild("Humanoid") then
humanoid=onTouch.Parent.Humanoid
explode=Instance.new("Explosion",humanoid.Parent)
humanoid.Health=humanoid.Health-100
end
end) |
|
|
I played the game for you. Looks really cool when you die with the smoke effects. |
|
|
@ Cool thank you.
It's not done yet I plan on adding DBZ moves when I become a professional Lua scripter. |
|
Mads898pJoin Date: 2013-11-09 Post Count: 41 |
Whut?! |
|
K7QJoin Date: 2013-03-23 Post Count: 5546 |
dont listen to cool he can't script.
do
Instance.new("Explosion", game.Workspace.Part) |
|
|
@K7Q I am very new to Lua also. That message was just to give him an idea of what to do. |
|
drager980Join Date: 2009-05-25 Post Count: 13385 |
local radius = 30 -- radius of explosion
local power = 200 -- power of explosion
local timer = 3 -- time to wait before it can blow up again
local debounce = false -- dont touch this one
script.Parent.Touched:connect(funciton()
if not debounce then
debounce = true
local e = Instance.new("Explosion",script.Parent)
e.BlastRadius = radius
e.BlastPressure = power
e.Position = script.Parent.Position
wait(timer)
debounce = false
end
end)
AND THE TIGER GOES ROAR |
|
|
I've already made the script and I've stated making a tool. |
|
Mads898pJoin Date: 2013-11-09 Post Count: 41 |
local radius = 30 -- radius of explosion
local power = 200 -- power of explosion
local timer = 3 -- time to wait before it can blow up again
local debounce = false -- dont touch this one
script.Parent.Touched:connect(funciton()
if not debounce then
debounce = true
local e = Instance.new("Explosion",script.Parent)
e.BlastRadius = radius
e.BlastPressure = power
e.Position = script.Parent.Position
wait(timer)
debounce = false
end
end) |
|
|
K7QJoin Date: 2013-03-23 Post Count: 5546 |
...? |
|
drager980Join Date: 2009-05-25 Post Count: 13385 |
lol i spelt function wrong
also if you do this you might want to do
script.Parent.Touched:Connect(function(hit)
if (not debounce) and not hit:IsGrounded()
-- rest
but it depends on what else you're going to do, and what hits what
|
|
|
Dark, Thank You for the script, but for some random reason it doesn't really work & keeps giving me errors. E.g; Workspace.Explodes When ################## attempt to index local 'Player' (a nil value) That's what happens & it's very sad & irritating to me that I have to keep changing or fixing errors when on the other hand, you & other people apparently said it worked which confuses me and I just am completely lost. Also, Please do not put the quotation marks as when I copy & paste it says 'String not complete.' Thank you, though and hope you can fix this error for me! |
|