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:
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
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.Velocity = (player.Character.Head.Position - mouse).LookVector * 350
game:GetService("Debris"):AddItem(BeachBall, 10)
end)
Have you tried debugging your code with print() statements or breakpoints to make sure it is all running when you click your mouse? Also your math seems a bit off, try something like (position1-position2).Unit*350. This is basically getting the directional vector between two positions (your character and your mouse), and normalizing it (making the vector have a magnitude of 1), and then changing the vectors magnitude to whatever you desire (350 in this case)
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.Velocity = (mouse - player.Character.Head.Position).unit * 350
game:GetService("Debris"):AddItem(BeachBall, 10)
end)
Use Unit instead, i already put that.
Explanation of Unit: Subtract from end position (mouse.Hit.p), start position (Head.Position), and then put .unit which will return vector3 direction, multiply it by 350 (or anything) and it should work. Try script i re-wrote. Let me know if it works