generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: I need help on a Mine script

Previous Thread :: Next Thread 
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 09:56 AM
function KillPlayer(Mine)
h = Mine.Parent.FindFirstChild("Humanoid")
if h ~= nil then
h.health = 0
e = Instance.new("Explosion")
e.Parent = game.Workspace.Mine
e.BlastRadius = 20
e.BlastPressure = 40
end
end

script.Parent.Touched:Connect(KillPlayer)

Im not sure where the problem is but nothing will happen when I step on the blick named "Mine"(Where the script is in). This script is ment to find the humanoid and kill them when they touch the brick and create an explosion, but its not.

~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
30 Jul 2012 09:59 AM
:findFirstChild("Humanoid")
not .

And use this:
e.Parent = workspace
e.Position = script.Parent.Position
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:00 AM
Thanks.

~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:04 AM
I just tryed it out and it didn't work. Heres what ive got at the moment. Same problem as before with it just not working when my charter touches it.


function KillPlayer(Mine)
h = Mine.Parent:FindFirstChild("Humanoid")
if h ~= nil then
h.health = 0
e = Instance.new("Explosion")
e.Parent = workspace
e.BlastRadius = 20
e.BlastPressure = 40
e.Position = script.Parent.Position
end
end

script.Parent.Touched:Connect(KillPlayer)




~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:09 AM
h.Health = 0

This is the only error I can find but this is my first script :/

~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:10 AM
By error I mean I found, I fixed it because originaly it was
h.health = 0

~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:12 AM
function KillPlayer(Mine)
****h = Mine.Parent:FindFirstChild("Humanoid")
****if h ~= nil then
********h.Health = 0
****e = Instance.new("Explosion")
****e.Parent = workspace
****e.BlastRadius = 20
****e.BlastPressure = 40
****e.Position = script.Parent.Position
****end
end

script.Parent.Touched:Connect(KillPlayer)


****=1 tab
********=2 tab


~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
30 Jul 2012 10:15 AM
Try this (a rewrite of your script):

script.Parent.Touched:connect(function (p)
if (not p.Parent:findFirstChild("Humanoid")) then return; end
p.Parent.Humanoid.Health = 0;
local e = Instance.new("Explosion", workspace);
e.Position = script.Parent.Position;
e.BlastRadius = 20;
e.BlastPressure = 40;
end);
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:18 AM
Thanks.
So do you know what was wrong with it in the end so I know for next time I script?

~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
30 Jul 2012 10:19 AM
Hmm, might have been because you wrote "Connect", not "connect". Lua is case-sensitive.
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Jul 2012 10:25 AM
This might be writing something completely different from what you have but here is the script I made for my TNT brick and it explodes when you step on it.

function onTouched(part)
local a = part.Parent:findFirstChild("Humanoid")
if a~=nil then
local Explosion = Instance.new('Explosion', Workspace)
Explosion.Parent = script.Parent
Explosion.Position = script.Parent.Position
Explosion.BlastRadius = 10
Explosion.BlastPressure = 10
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
30 Jul 2012 10:26 AM
@Milky: That is pretty much the same, except OP's sets the health of the humanoid to 0 as well, though I suppose that might not be needed as the explosion might kill them anyway.
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:27 AM
Hmm, its not that, I just tried it.

~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Jul 2012 10:32 AM
I guess it's similar to mickyy5's but either way my script works. Normally the explosion kills them but if you want to make sure you could just add this line
a.Health = 0
Report Abuse
mickyy5 is not online. mickyy5
Joined: 20 Feb 2010
Total Posts: 11059
30 Jul 2012 10:38 AM
I would rather learn what my mistakes are than be handed scripts because im trying to learn what to do right.

~For our Empire, We Strike Our Enemy ~ Silvaina Forever.
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Jul 2012 10:41 AM
There is 1 more thing that could be the problem. The brick is named "Mine" and so is a part of the function. This might not work but change the name of either the brick or the function part to something other than Mine because it might be confusing the game.
Report Abuse
MilkyWay01 is not online. MilkyWay01
Joined: 22 Feb 2010
Total Posts: 1049
30 Jul 2012 10:43 AM
nvm didn't know it was already fixed
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image