So here I have two scripts, local script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local bombModel = game:GetService("ReplicatedStorage")["TNT STICK"]
local explosionAnimation = game:GetService("ReplicatedStorage").Throwing
local motor6D = game:GetService("ReplicatedStorage").Motor6D
local function throwBomb()
local Humanoid = player.Character:WaitForChild("Humanoid")
local Animator = Humanoid:FindFirstChildOfClass("Animator")
if Animator then
local clone = bombModel:Clone()
clone.Parent = player.Character.RightHand
motor6D.Parent = player.Character.RightHand
motor6D.Part0 = player.Character.RightHand
motor6D.Part1 = player.Character.RightHand["TNT STICK"].Circle
local animation = Animator:LoadAnimation(explosionAnimation)
animation:Play()
game:GetService("ReplicatedStorage").ThrowingEvent:FireServer(mouse.Hit.p)
print("1")
wait(1.5)
motor6D.Parent = game:GetService("ReplicatedStorage")
clone:Destroy()
end
end
mouse.Button1Down:Connect(throwBomb)
In this script, when I click on the left mouse button, I produce an animation and call the event with which I plan to move the dynamite, which I throw forward. As if I threw it
And here is my usual script:
local tool = script.Parent
print(tool)
game:GetService("ReplicatedStorage").ThrowingEvent.OnServerEvent:Connect(function(player, event)
print(player)
local mouse = player:GetMouse()
local ball = tool.Handle
tool.Parent = workspace
ball.CFrame = tool.Handle.CFrame
ball.CFrame = CFrame.new(ball.Position, event)
local BV = Instance.new("BodyVelocity", ball);
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = ball.CFrame.lookVector * 50 -- how fast it throws
wait(.1)
tool.Handle.BodyVelocity:Destroy()
end)
in it, I want to throw the object forward, but for some reason, this event is just not called, what is the problem?