I’m trying to make a throwable ball but it doesn’t really getting shot out. I want it to shoot out to the direction my HumanoidRootPart is facing. I’m trying to implement this using ApplyImpulse but I don’t really know how to use such thing. I’ve been to the wiki but I didn’t understand anything.
This is what I have so far:
Client:
local tool = script.Parent
local remoteEvent = tool.RemoteEvent
tool.Activated:Connect(function()
remoteEvent:FireServer()
end)
Server:
local tool = script.Parent
local handle = tool.Handle
local remoteEvent = tool.RemoteEvent
remoteEvent.OnServerEvent:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:FindFirstChild("RootPart")
local projectile = handle:Clone()
projectile:ApplyImpulse(Vector3.new(10000,0,0))
projectile.Parent = workspace
end)
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local remoteEvent = tool:WaitForChild("RemoteEvent")
remoteEvent.OnServerEvent:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:FindFirstChild("RootPart")
local projectile = handle:Clone()
projectile.Parent = workspace
projectile:ApplyImpulse(Vector3.new(0, 0, 10))
end)
and I used a lower impulse for testing purposes. OP had it at 10k on the X axis, where I have it to 10 on the Z.
They just weren’t live, there was no bug. Although the functions have been live for a while now. And I never used a body force or used network ownership?
local tool = script.Parent
local handle = tool.Handle
local remoteEvent = tool.RemoteEvent
remoteEvent.OnServerEvent:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:FindFirstChild("RootPart")
local projectile = handle:Clone()
projectile.Parent = workspace
projectile:ApplyImpulse(rootPart.CFrame.LookVector * 1000)
end)
i know this is pretty old and im necroposting but just incase he never found out and/ or for future reference im just gonna say, you’d have to create a new vector saying local vector = Vector3.new(character.PrimaryPart.CFrame.LookVector.X, --insert y here, character.PrimaryPart.CFrame.LookVector.Z and after that write projectile:ApplyImpulse(vector * 1000)