So basically I have a beach ball tool that you can buy that’s all good but I want it to be throwable when you click. I don’t really want others to be able to pick it up but if I can’t do that then it’s fine because I can just make it go back into your inventory after it’s thrown but I don’t know how to actually make it like go and throw after you click. Can someone help me with this? The beach ball is a tool in ReplicatedStorage that gets parented to the player’s backpack when they purchase it.
1 Like
Use the tool’s Activated event, then clone the ball itself into the workspace and add a BodyForce to it. Might wanna set its network owner to nil as well.
1 Like
local ball = game:GetService("ReplicatedStorage").BaseBall:Clone()
local tool = script.Parent
local velocity = game.ReplicatedStorage.BodyVelocity:Clone()
local mouse = game.Players.LocalPlayer:GetMouse()
tool.Activated:Connect(function()
ball.Parent = workspace
ball.Position = script.Parent.Handle.Position
velocity.Velocity = mouse.Hit.Position
velocity.Parent = ball
end)
1 Like
what would the network owner do?
That wont work, that’ll just fling the ball. You need to use a look vector and multiply it by an arbitrary number. Another reason being that you cant just set the ball’s velocity on the client.
ex:
-- 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 baseball = game.ReplicatedStorage.BaseBall:Clone()
baseball.Parent = workspace
baseball.Velocity = (player.Character.Head.Position - mouse).LookVector * 350
game:GetService("Debris"):AddItem(baseball, 10)
end)
I’ll try that later but that would only work if the player has the tool right because that’s how I want it to be since you have to buy the tool first
this didn’t work I put the local part in a local script parented to the tool and the server part in a server script and it still won’t work