I want to create a tool that makes a ball that goes in the direction of when the player clicked. When the player clicks it creates the ball but the ball does not go anywhere.
-- Local
local tool = script.Parent
local RS = game:GetService("ReplicatedStorage")
local createPartEvent = RS:WaitForChild("CreatePartEvent")
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
local ray = Ray.new(
tool.Tip.CFrame.p,
(mouse.Hit.p - tool.Tip.CFrame.p).unit * 300
)
local ignore = game:GetService("Players").LocalPlayer.Character
local hit, position = workspace:FindPartOnRay(ray, ignore, false, true)
print(position)
createPartEvent:FireServer(hit, position)
end)
end)
-- Server
local RS = game:GetService("ReplicatedStorage")
local createPartEvent = Instance.new("RemoteEvent")
local tool = script.Parent
createPartEvent.Parent = RS
createPartEvent.Name = "CreatePartEvent"
createPartEvent.OnServerEvent:Connect(function(player, hit, position)
local ball = Instance.new("Part")
ball.Parent = workspace
ball.BrickColor = BrickColor.new("Bright red")
ball.Material = "Neon"
ball.Shape = "Ball"
ball.Transparency = .25
ball.Anchored = true
ball.CanCollide = false
ball.Size = Vector3.new(2,2,2)
ball.CFrame = tool.Tip.CFrame
local bv = Instance.new("BodyVelocity")
bv.Parent = ball
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.P = 10000
bv.Velocity = position
end)
