✓ Accepted answer
Let's disregard what you did because your script is heavily incomplete, no call is being taken place, plus this is not how you'd activate the function by pressing a ScreenGui.
I do Not know you hierarchy, so I cannot say my script will go to the correct places, but I'll make it so you need to put it inside of the TextButton.
This is to be for a LocalScript !
Make sure the tools are inside of 'ReplicatedStorage' !
Look bellow this script for information!
sp = script.Parent
player = game.Players.LocalPlayer
sp.MouseButton1Click:connect(function()
local KF5Dot = game.ReplicatedStorage:FindFirstChild("KF5Dot"):Clone()
KF5Dot.Parent = player.Backpack
end)
Due to this being a LocalScript, we can use LocalPlayer which is pretty helpful. Now, doing KF5Dot.Parent = will assign where this clone is going to, in this case, the players Backpack.
Now, to clear our the tools in the Backpack, you'd do this script (Still a LocalScript inside of a TextButton)
sp = script.Parent
player = game.Players.LocalPlayer
sp.MouseButton1Click:connect(function()
local All_Tools = player.Backpack:GetChildren()
for _, Tool in pairs(All_Tools) do
Tool:remove()
end
end)
This script is going through each item in your backpack using a Generic For loop, then removing them. for _,Tool- Tool is actually going to be the Tool in backpack, which is why I did Tool:remove()!
3 comments
Is it a Local script? You have a lot of problems but we need to know if your script is local...
its local
TrollD3, tell me how does the answer work. What is LocalPlayer what is MouseButton1Click what is clone and what is FindFirstChild. Did you learn anything. Do not accept answers if they do not have an explanation.