Local Script:
local uis = game:GetService("UserInputService")
local tool = script.Parent
local anim = tool:WaitForChild("Throw")
local track = nil
local event = tool:WaitForChild("ThrowingEvent")
local equipped = false
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
tool.Equipped:Connect(function()
equipped = true
local char = tool.Parent
local humanoid = char:WaitForChild("Humanoid")
local track = humanoid.Animator:LoadAnimation(anim)
mouse.Button1Down:Connect(function()
event:FireServer()
end)
end)
tool.Unequipped:Connect(function()
equipped = false
end)
uis.InputBegan:Connect(function(input)
if equipped and input.UserInputType == Enum.UserInputType.MouseButton1 then
track:Play()
end
if equipped and input.UserInputType == Enum.UserInputType.Touch then
track:Play()
end
end)
Script:
local tool = script.Parent
local event = script.Parent:WaitForChild("ThrowingEvent")
local debris = game:GetService("Debris")
event.OnServerEvent:Connect(function(player)
local dynamite = tool.Handle:Clone()
dynamite.Parent = workspace
dynamite.CanCollide = true
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local dir = hrp.CFrame.LookVector + hrp.CFrame.UpVector
dynamite.VectorForce.Force = dir * 200
tool:Destroy()
wait(0.2)
dynamite.VectorForce.Enabled = false
wait(1.5)
dynamite.ExploseSound:Play()
local vfx = Instance.new("Explosion", workspace)
vfx.Position = dynamite.Position
vfx.BlastRadius = 20
vfx.BlastPressure = 500000
dynamite.Transparency = 1
dynamite.Anchored = true
dynamite.CanCollide = false
debris:AddItem(dynamite, 2.2)
end)
So here I have a script to throw dynamite, but only for some reason that appears here is the error, why?