I have a tool in replicatedstorage that goes in the player’s backpack when they purchase the item and 2 scripts that are supposed to make the ball throw when the player clicks but they dont work. This is the ball tool in replicatedstorage
This is the localscript inside:
-- Client --
local mouse = game.Players.LocalPlayer:GetMouse()
local remote = game.ReplicatedStorage.RemoteEvent
local tool = script.Parent
tool.Activated:Connect(function()
remote:FireServer(mouse.Hit.p)
end)
and this is the server script in serverscriptservice
-- Server --
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(player, mouse)
if not player.Character:FindFirstChild("Beach Ball") then return end
local BeachBall = game.ReplicatedStorage["Beach Ball"]:Clone()
BeachBall.Parent = workspace
BeachBall.Position = player.Character["Beach Ball"].Handle.Position
BeachBall.AssemblyLinearVelocity = (mouse - player.Character.Head.Position).unit * 350
game:GetService("Debris"):AddItem(BeachBall, 10)
end)
Hey, so if your planning on adding physics to this beachball. Then I would highly recommend using Bezier Curves.
I’ve made my own gun with implemented physics too it.
Make a new tool make a handle for it, and put this code inside of a local script inside. You’ll understand what I’m talking about once you do it. I made this script myself so yea.
function c(t, p0, p1, p2)
return (1 - t)^2 * p0 + 2 * (1 - t) * t * p1 + t^2 * p2
end
script.Parent.Activated:Connect(function()
local Mouse = game.Players.LocalPlayer:GetMouse()
local Part = Instance.new("Part"); Part.Color = Color3.fromRGB(255, 85, 0); Part.Shape = "Ball"; Part.Size = Vector3.new(1,1,1); Part.Anchored = true; Part.CanCollide = false
Mouse.TargetFilter = Part
local x,y,z = Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z
game.Debris:AddItem(Part, 5)
local v = (script.Parent.Handle.Position + Mouse.Hit.Position)/2 + Vector3.new(0,y + 10,0)
for i = 0, 1, 0.05 do
Part.Parent = game.Workspace
local pos = c(i,script.Parent.Handle.Position,v,Vector3.new(x,y,z))
Part.Position = pos
wait()
end
Part.Position = Part.Position - Vector3.new(0,1,0)
end)