Tool on the ground disappear

Where should I place this code?

Anywhere practical, probably inside of the tool, it depends what you intend to do.

If you are literally going to destroy the football and do nothing else then put that code in the tool, set the football variable to “script.Parent.Parent”

image

local football = football_path_here
local function DeleteThatFootball()
	if football.Parent.ClassName == "Backpack" then
		local counter = 0
		repeat wait(1); counter = counter+1 until football.Parent.ClassName ~= "Backpack" or counter == 10
		if football.Parent.ClassName == "Backpack" then
			football:Destroy()
		end
	end
end
local deletecoroutine = coroutine.wrap(DeleteThatFootball)

football:GetPropertyChangedSignal("Parent"):Connect(function()
	deletecoroutine()
end)
local used = false
local tool = script.Parent


tool:GetPropertyChangedSignal('Parent'):Connect(function()
	if tool.Parent:FindFirstChild('Humanoid') then
		used = true
	end
end)

game:GetService('RunService').Stepped:Connect(function(dt)
	if not used then
		task.wait(10)
		tool:Destroy()
	end
end)

This should work, put the server script inside the tool.

There is an issue. When the player would take out the tool it would put used to true. Once they unequip it, used is false. That triggers a wait(10) which by the way people can equip the football in that time, and while someone is using it then it will be destroyed randomly.

The best resolution is using what I have made up above using coroutines and stopping countdowns if the player equips it again, stopping this issue from happening.

1 Like

Ok, let me test this real fast.

This script is not working for me.

Which script is not working? 30

Well the “football path here is underlined”

Where is the script located? I can tell you what to put in with that info.

Also, please use this script, I have fixed a few errors.

wait(1)
local football = script.Parent
local function DeleteThatFootball()
	if football.Parent.ClassName == "Backpack" then
		local counter = 0
		repeat wait(1); counter = counter+1 until football.Parent.ClassName ~= "Backpack" or counter == 10
		if football.Parent.ClassName == "Backpack" then
			football:Destroy()
		end
	end
end

football:GetPropertyChangedSignal("Parent"):Connect(function()
	local deletecoroutine = coroutine.wrap(DeleteThatFootball)
	deletecoroutine()
end)

Errors with old: “cannot resume dead coroutine”
Issues with old: At the start, people could lose their tool without equipping it for the first time. You don’t want that to happen.

If the script is located in the handle of the tool, put

local football = script.Parent.Parent

It is located in the handle. 000000

It is still not disappearing. 0000000000

Did you make sure you used my updated script? The script that has wait(1) at the top.

You can use the Touched event:
tool.Touched:Connect(function(hit)
if hit:FindFirstChild(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
– wait 10 seconds then remove the tool
wait(10)
tool:Destroy()
end
end)

Would I replace the current script with this or add this onto the other?

workspace.ChildAdded:Connect(function (child) --Run a line of code each time something is parented to workspace and "child" is the thing added
if child:IsA("Tool") then --Check to see if the item is a tool
local StartTime = tick() --Tick is time that increase every, well tick. we save the current tick to use it later
local LifeTime = 10
local stopCountdown = false
local toolPickedupCheck = child:GetPropertyChangedSignal("Parent"):Connect(function() --so we know if the tool is picked up
stopCountdown=true --stop the countdown 
end)
repeat wait() until tick()-StartTime >= LifeTime or stopCountdown
toolPickedupCheck:Disconnect() --stop the event  from firing
if not stopCountdown then --if it reaches the end without getting picked up
child:Destroy()
end
end
end)

sorry for not being formated, i wrote the script in here and might have misspelled somethings lol

This script does not work. I don’t know why

Make a SERVERSCRIPT inside the SAID TOOL

local __TOOL = script.Parent
local __TICK = tick()

__TOOL.Changed:Connect(function(__ARGS)
    __TICK = tick()
    task.delay(20, function()
       if __TOOL.Parent == workspace and not __TOOL.Parent:IsA("Model") then
          __TOOL:Destroy()
       end
    end)
end)

What do you mean by said tool and serverscript???