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)

1 comment
Please tab your code. It makes it much easier to read.