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

How to make this do 5 damage per arrow?

Asked by 10 years ago

It's a arrow trap I made, but I only know how to make it break your joints when the arrow collides with you. Anyways of making it do only 5 damage per arrow?

function Stick(x, y)
    weld = Instance.new("Weld") 
    weld.Part0 = x
    weld.Part1 = y
    local HitPos = x.Position
    local CJ = CFrame.new(HitPos) 
    local C0 = x.CFrame:inverse() * CJ 
    local C1 = y.CFrame:inverse() * CJ 
    weld.C0 = C0 
    weld.C1 = C1 
    weld.Parent = x
end

function onTouched(hit)
local player = Game.Players:FindFirstChild(hit.Parent.Name)
if player ~= nil then
local arrow = Instance.new("Model",script.Parent.Parent)
arrow.Name = "Arrow"
local base = Instance.new("Part",arrow)
base.BrickColor = BrickColor.new("Dark orange")
base.CanCollide = false
base.FormFactor = "Symmetric"
base.Size = Vector3.new(1,2,1)
base.CFrame = script.Parent.Parent.Shooter.CFrame
local mesh = Instance.new("CylinderMesh",base)
mesh.Scale = Vector3.new(0.35,1,0.35)
local tip = Instance.new("Part",arrow)
tip.BrickColor = BrickColor.new("Really black")
tip.CanCollide = false
tip.FormFactor = "Symmetric"
tip.Size = Vector3.new(1,2,1)
tip.CFrame = base.CFrame
tip.CFrame = tip.CFrame + tip.CFrame.lookVector * 1.5
local mesh = Instance.new("SpecialMesh",tip)
mesh.MeshId = "http://www.roblox.com/asset/?id=1033714"
mesh.MeshType = "FileMesh"
mesh.Scale = Vector3.new(0.3,1.5,0.3)
base.CFrame = base.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(90),0,0)
tip.CFrame = tip.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(-90),0,0)
Stick(base, tip)
local bv = Instance.new("BodyVelocity",tip)
bv.velocity = script.Parent.Parent.Shooter.CFrame.lookVector * script.Parent.Parent.Configuration.Speed.Value
local basehurt = base.Touched:connect(function(touched)
local player = Game.Players:FindFirstChild(touched.Parent.Name)
if player ~= nil then
player.Character:BreakJoints()
end
end)
local tiphurt = tip.Touched:connect(function(touched)
local player = Game.Players:FindFirstChild(touched.Parent.Name)
if player ~= nil then
player.Character:BreakJoints()
end
end)
wait(3)
basehurt:disconnect()
tiphurt:disconnect()
arrow:Remove()
end
end

script.Parent.Touched:connect(onTouched)
0
Please tab your code. It makes it much easier to read. BlueTaslem 18071 — 10y

2 answers

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

Change line 52 to

player.Character:FindFirstChild("Humanoid"):TakeDamage(5)
Ad
Log in to vote
-2
Answered by 10 years ago
Damage = game.Players:FindFirstChild("Humanoid")

        Damage = -5
0
This is not even slightly close to being correct. BlueTaslem 18071 — 10y
0
I agree. I'm an amateur scripter, and I know that's not even correct, BlueTaslem. TheRings0fSaturn 28 — 10y
0
sorry i am a very beginner scripter blockhaak2 1 — 10y
0
Don't try to help if you don't know what you're talking about, it'll only confuse the OP more. Ekkoh 635 — 10y

Answer this question