So, I have this baseball game and I need help on something pretty simple, I’d say. Below is a video of my problem. I don’t want to pick up the ball while I have my bat out, but I want to be able to pick it up if I don’t have a bat.
This script should work, put it on StarterCharacterScripts
local character = script.Parent
local p = game.Players:GetPlayerFromCharacter(character)
character.ChildAdded:Connect(function(ch)
if ch:IsA("Tool") then
task.wait()
for _, c in pairs(character:GetChildren()) do
if c:IsA("Tool") and c ~= ch then
ch.Parent = p.Backpack
end
end
end
end)
It basically moves the ball to the backpack if there is already a tool out.
Change ch.Parent = p.Backpack to ch.Parent = workspace
If you are still unsatisfied i suggest not making the ball a tool.
And instead putting the viewmodel of the tool and storing the original tool on ServerStorage and a touch script so it gives you the original tool (with checks)