Why isn't this beach ball throw script working?

I have a script that should throw my beach ball tool when you click, but it isn’t working. Can someone help?
The beach ball is a tool in replicatedstorage and the script that isn’t working is inside of it. There is also a clicked remoteevent in replicatedstorage as well.
Screen Shot 2021-06-22 at 12.33.12 PM
Here is the script:

-- 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)

-- Server -- 
local remote = game.ReplicatedStorage.RemoteEvent

remote.OnServerEvent:Connect(function(player, mouse)
	if not player.Character:FindFirstChild("ToolName") then return end

	local BeachBall = game.ReplicatedStorage["Beach Ball"]:Clone()
	BeachBall.Parent = workspace
	BeachBall.Velocity = (player.Character.Head.Position - mouse).LookVector * 350

	game:GetService("Debris"):AddItem(BeachBall, 10)
end)

this only works in a local script because you tried to get the local player

you sure this is in a local script?

1 Like

I put the client part in a local script and the other part in a server script and it still doesn’t work should I just put it all in a localscript?

just a general tip, put the server script in a place like serverscriptservice, otherwise it would probably cause issues, and it would reduce lag as there would only be 1 script then, instead of having one for each player.

It might even fix the issue, though i doubt it would

yea I did that but its not working

where is the local script located?

its parented to the tool
30char

and the tool is parented to the players backpack when they are playing, correct?

it only parents the tool to the backpack when they purchase the item or have it already

so when you are player and testing it, its parented to the backpack?

once I buy it its parented to the backpack and I buy it to test it since I haven’t coded the purchase saving part yet

Could you show us the explorer tab of the actual tool the player holds?
I want to make sure the tool is called “ToolName,” otherwise the script returns prematurely.

Also I want to note that these lines won’t work as desired, as BeachBall is a Tool instance. Tools can’t have velocity set, only BaseParts.

if not player.Character:FindFirstChild("ToolName") then return end

are you sure the tool is named “ToolName” ?

oh someone helped me with this the tool isn’t tool name ill have to fix that
thats in the server script btw

I changed it to

if not player.Character:FindFirstChild("Beach Ball") then return end

but it still won’t work


This is the server script btw the client part is in a local script

you are maybe forgetting setting the position

wait what im confused bc im not very good with this stuff

just a tip
image
you shouldn’t name them all the same thing

1 Like

you have possibly forgot setting the beach balls position

what would the position be if I just want it to be thrown im not very good with this because I’ve never done anything like this before