Hello, so I have a football training game, and when you throw the football the only way to get it back is to grab it or reset. Is there any way to make it so the player presses a button to put a football in their inventory?
Hello, so I have a football training game, and when you throw the football the only way to get it back is to grab it or reset. Is there any way to make it so the player presses a button to put a football in their inventory?
Here is what I have so far:
local football = workspace.Football – path here
local btn = script.Parent
local backup = football:Clone()
backup.Parent = game:GetService(“ReplicatedStorage”)
btn.MouseButton1Click:Connect(function()
if football then
local newball = football:Clone()
newball.Parent = workspace
newball.Name = “Football”
football:Destroy()
else
local newball = backup:Clone()
newball.Parent = workspace
newball.Name = “Football”
end
end)
local football = -- ball path
local btn = script.Parent
local p = game.Players.LocalPlayer
btn.MouseButton1Click:Connect(function()
football:Clone().Parent = p.Backpack
end)
This is a crude script to clone the ball into the player’s backpack.
The above script is the script that should work. Put it in your gui button. However, make sure to replace the “ball path” with your ball’s path, e.g. game.ReplicatedStorage.Football
I want it so the player does not spawn with the football, but once they click the button it gives them a football. They can throw it and press the button to get another one.