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