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
 

Arrow OnTouched script Failing.

Previous Thread :: Next Thread 
Twala is not online. Twala
Joined: 01 Nov 2008
Total Posts: 6799
12 May 2012 06:23 PM
Hello.

This script is supposed to make it so when the arrow (Script is inside Arrow) Hits a target, it either damages if a Humanoid, of lodges into it.

Everything works fine. The thing that isn't working is the part that says if it hits your Head, it does 100 damage instead of 50, and the Shooter gets a badge.

Instead, if you hit someone in the head, it only does 50 Damage, and no badge. I think its a problem with the end placement, PLEASE HELP!

local arrow = script.Parent


local damage = 50
local deb = false

local weld = Instance.new("Weld")
weld.Part0 = arrow
weld.Parent = arrow

function onTouch(hit)
if hit.Parent then
vChar = hit.Parent
humanoid = vChar:FindFirstChild("Humanoid")
if humanoid and deb == false then
deb = true
local tag = arrow:FindFirstChild("creator")
if tag then tag.Parent = humanoid

end
if hit.Name == "Head" then
damage = 100
ownr = humanoid:FindFirstChild("creator")
if ownr then
p = game.Players:FindFirstChild(ownr.Value)
if p then
b = game:GetService("BadgeService")
b:AwardBadge(p.userId, 80690791)
end
end
end
humanoid:TakeDamage(damage)
weld.Part1 = hit
else
weld.Part1 = hit
weld.C0 = CFrame.new(arrow.Position - hit.Position)
end
end
end

arrow.Touched:connect(onTouch)

wait(2)
arrow:Remove()
Report Abuse
Twala is not online. Twala
Joined: 01 Nov 2008
Total Posts: 6799
12 May 2012 06:29 PM
Halp!
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
12 May 2012 06:34 PM
It might be hit.name, lower-case.

Put a print before that if, print("hit = ", hit, hit.name, hit.parnet)
Report Abuse
Twala is not online. Twala
Joined: 01 Nov 2008
Total Posts: 6799
12 May 2012 06:35 PM
Theres no output, so Im guessing I failed on the placement of ends or an if--then is wrong.
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
12 May 2012 06:39 PM
move the Print up to before the first If.
Report Abuse
Twala is not online. Twala
Joined: 01 Nov 2008
Total Posts: 6799
12 May 2012 07:33 PM
Help -.-t
Report Abuse
zrainfall is not online. zrainfall
Joined: 28 Apr 2012
Total Posts: 129
12 May 2012 07:56 PM
There's an end that seems to finish the script before time. It's right where there's an enter in the script you posted.
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
12 May 2012 08:15 PM
Buddy,

Your're gonna have to get it to print something, or it's just not getting there.

Open view>output, and read what it says.
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