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
 

Help me with this script

Previous Thread :: Next Thread 
swordron is not online. swordron
Joined: 23 Jun 2008
Total Posts: 27432
31 Jul 2014 07:17 PM
The zombie is called "walker" so I changed the humanoid to walker. But it doesn't want to give damage to the walker...

ball = script.Parent
damage = math.random(18,24)
local hitt = false

HitSound = Instance.new("Sound")
HitSound.Name = "HitSound"
HitSound.SoundId = "http://www.roblox.com/asset/?id=11945266"
HitSound.Pitch = .8
HitSound.Volume = 1
HitSound.Parent = ball

function onTouched(hit)
if hit.Parent:findFirstChild("ForceField") ~= nil then return end
if hit.CanCollide == false and hit.Parent:findFirstChild("Walker") == nil then return end
if hit.Parent.className == "Hat" and hitt == false then
hitt = true
hit:BreakJoints()
hit.Velocity = ball.Velocity
hit.Parent.Parent = game.Workspace
end

if hit:findFirstChild("Metal") ~= nil and hitt == false then
hitt = true
for i = 1,math.random(1,3) do
local j = Instance.new("Part")
j.formFactor = "Plate"
j.Size = Vector3.new(1,.4,1)
j.BrickColor = BrickColor.new("Bright yellow")
j.CanCollide = false
j.Velocity = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
j.CFrame = script.Parent.CFrame
j.Parent = game.Workspace
end
end

local humanoid = hit.Parent:findFirstChild("Walker")

if humanoid ~= nil and hitt == false then
hitt = true
tagHumanoid(humanoid)
if hit.Name == "Head" then
humanoid.Health = humanoid.Health - damage * 30
elseif hit.Name == "Torso" then
humanoid.Health = humanoid.Health - damage * 15
else
humanoid.Health = humanoid.Health - damage
end
wait(.2)
untagHumanoid(humanoid)
end
if hitt == true then
HitSound:play()
ball.Parent = nil
end
end

function tagHumanoid(humanoid)
-- todo: make tag expire
local tag = ball:findFirstChild("creator")
if tag ~= nil then
local new_tag = tag:clone()
new_tag.Parent = humanoid
end
end


function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:GetChildren()

for i = 1, #tag do

if tag[i].Name == "creator" then
tag[i]:remove()
end

end
end
end

connection = ball.Touched:connect(onTouched)

while true do
wait(.01)
if damage < 0 then
break
else
damage = damage - .2
end
end

ball.Parent = nil
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:17 PM
change:

if hit.CanCollide == false and hit.Parent:findFirstChild("Walker") == nil then return end

with

if hit.CanCollide == false and hit.Parent:findFirstChild("Humanoid") == nil then return end
Report Abuse
swordron is not online. swordron
Joined: 23 Jun 2008
Total Posts: 27432
31 Jul 2014 07:20 PM
Its still not working.
Report Abuse
alij12 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
31 Jul 2014 07:57 PM
also replace:

local humanoid = hit.Parent:findFirstChild("Walker")

with

local humanoid = hit.Parent:findFirstChild("Humanoid")
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