-
What do you want to achieve? A working bow
-
What is the issue? My bow was working but when I moved it out of starter pack into a text button so that I could give it to other players when they clicked the button it stopped working.
-
What solutions have you tried so far? I have tried DevForum and Adjusting the code
My code so far:
local tool = script.Parent
local handle = tool:WaitForChild(‘Handle’)
local event = tool:WaitForChild(‘RemoteEvent’)
local debounce = true
local CoolDownTime = 3
local Arrow = game.ReplicatedStorage.Arrow
event.OnServerEvent:connect(function(player,pos)
local newArrow = Arrow:clone()
local humanoid = tool.Parent:FindFirstChildWhichIsA(‘Humanoid’)
if humanoid and humanoid.Health > 0 and debounce == true then
debounce = false
local newArrow = Arrow:Clone()
newArrow.Parent = workspace
newArrow.CanCollide = false
newArrow.CFrame = CFrame.new(handle.Position,pos)
local Velocity = Instance.new(‘BodyVelocity’)
Velocity.Parent = newArrow
Velocity.Velocity = newArrow.CFrame.LookVector.Unit*300
Velocity.MaxForce = Vector3.new(‘inf’, ‘inf’, ‘inf’)
newArrow.Touched:connect(function(hit)
local human = hit.parent:FindFirstChildWhichIsA(‘Humanoid’)
if human and human.health > 0 and human ~= humanoid then
human:takedamage(20)
newArrow.destroy()
elseif not human and hit.CanCollide == true and not hit:IsDescendantOf(humanoid.parent) and not hit:IsDescendantOf(tool) then
if Velocity then
Velocity:Destroy()
end
local weld = Instance.new(‘WeldConstraint’)
weld.Parent = newArrow
weld.Part0 = newArrow
weld.Part1 = hit
Arrow.Massless = true
newArrow.CanCollide = false
end
end)
game.Debris:AddItem(newArrow, 5)
wait(CoolDownTime)
debounce = true
end
end)
Please help me, ASAP All help appreciated thank you for reading this and if you help out also thanks.