I made it like a video tutorial (tutorial) without using a plugin. It doesn’t work.
I don’t know what the reason is…
Help…
Error message: Arrow is not a valid member of Tool “Workspace.PlayerName.Bows”
※ I used Google Translate.
Using plugins : youtube : Roblox Studio Bow & Arrow Tutorial - YouTube
No plugins : youtube : How to Make a BOW | HowToRoblox - YouTube
– server script
– Settings –
local Damage = 30
local Cooldown = 0.5
local ChargeTime = 1
local ArrowVelocity = 150
local MinChargeTime = 0.25
local HoldingAnimationId = “http://www.roblox.com/asset/?id=8446158851”
– you’ll have to change these animation ids
local ChargingAnimationId = “http://www.roblox.com/asset/?id=8446454852”
local ChargedAnimationId = “http://www.roblox.com/asset/?id=8446482502”
local FireAnimationId = “http://www.roblox.com/asset/?id=8446502515”
local ArrowLifeTime = 30
– Variables –
local RemoteEvent = script.Parent:WaitForChild(“Update”)
local LastFire = tick()
local ChargeStart = tick()
– Script –
RemoteEvent.OnServerEvent:Connect(function(plr, Type, LookVector, RightVector)
local Tool = script.Parent
local Player = plr – Tool.Parent.Parent
local Character = workspace:WaitForChild(Player.Name)
local Humanoid = Character:FindFirstChildOfClass(“Humanoid”)
local IsCharging = false
local Arrow = game.ReplicatedStorage.Arrow
– Animations –
local Anim1 = Instance.new(“Animation”)
Anim1.AnimationId = HoldingAnimationId
local HoldingAnimation = Humanoid:LoadAnimation(Anim1)
local Anim2 = Instance.new(“Animation”)
Anim2.AnimationId = ChargingAnimationId
local ChargingAnimation = Humanoid:LoadAnimation(Anim2)
local Anim3 = Instance.new(“Animation”)
Anim3.AnimationId = ChargedAnimationId
local ChargedAnimation = Humanoid:LoadAnimation(Anim3)
local Anim4 = Instance.new(“Animation”)
Anim4.AnimationId = FireAnimationId
local FireAnimation = Humanoid:LoadAnimation(Anim4)
if Type == “Activated” then
if tick()-LastFire > Cooldown then
ChargeStart = tick()
IsCharging = true
script.Parent.Arrow.Transparency = 0
ChargingAnimation:Play()
wait(ChargingAnimation.Length)
ChargedAnimation:Play()
end
elseif Type == “Deactivated” then
ChargedAnimation:Stop()
script.Parent.Arrow.Transparency = 1
if tick()-ChargeStart > MinChargeTime then
FireAnimation:Play()
LastFire = tick()
– Fire an Arrow
local A = Arrow:Clone()
A.Parent = workspace
A.CFrame = script.Parent.Arrow.CFrame
A.Sender.Value = Character
local Ignore = {Character}
for i, Part in pairs(workspace:GetDescendants()) do
if Part:IsA(“BasePart”) then
if not Part.CanCollide then
table.insert(Ignore, Part)
end
end
end
local params = RaycastParams.new()
params.FilterDescendantsInstances = Ignore
params.FilterType = Enum.RaycastFilterType.Blacklist
local results = workspace:Raycast(Character.HumanoidRootPart.Position, Character.HumanoidRootPart.Position+LookVector*10, params)
if not results then
A.Position = A.Position+RightVector*2.5
end
– Calculate the Velocity and Damage
if tick()-ChargeStart < ChargeTime then
A:ApplyImpulse(LookVector*(tick()-ChargeStart)ArrowVelocity)
A.Damage.Value = Damage(tick()-ChargeStart)
else
A.Damage.Value = Damage
A:ApplyImpulse(LookVectorChargeTimeArrowVelocity)
end
– Schedule Deletion
game.Debris:AddItem(A, ArrowLifeTime)
end
IsCharging = false
elseif Type == “Equipped” then
HoldingAnimation:Play()
elseif Type == “Unequipped” then
IsCharging = false
script.Parent.Arrow.Transparency = 1
ChargingAnimation:Stop()
ChargedAnimation:Stop()
HoldingAnimation:Stop()
end
end)
– client script
local RemoteEvent = script.Parent:WaitForChild(“Update”)
local Tool = script.Parent
local Camera = workspace.CurrentCamera
Tool.Activated:Connect(function()
RemoteEvent:FireServer(“Activated”)
end)
Tool.Deactivated:Connect(function()
RemoteEvent:FireServer(“Deactivated”, Camera.CFrame.LookVector, Camera.CFrame.RightVector)
end)
Tool.Equipped:Connect(function()
RemoteEvent:FireServer(“Equipped”)
end)
Tool.Unequipped:Connect(function()
RemoteEvent:FireServer(“Unequipped”)
end)