So my tool drop on death is having a tiny bug that i dont know how to fix
local Character = script.Parent
wait(1)
Character.Humanoid.Died:connect(function()
for i, tool in pairs(Character:GetChildren()) do
if tool:IsA("Tool") then
if tool.Name == "Fist" then return end
if tool.Name == "FlashLight" then return end
tool.Parent = game.Workspace
tool:WaitForChild("Handle").ProximityPrompt.HoldDuration = 5 -- this is the issue
end
end
end)
so im pretty sure the script cant find the handle, but i dont know what the problem is…
So basically this script is a tool drop on death , so when the character is dead the item the character holds goes into workspace. So my issue is that the proximityprompt hold duration isnt changing (the proximityprompt is in the handle of the tool) the reason why i need this to change is because players can instantly pick up guns on floors (because the proximityprompt is to pick up the item if its in workspace)
Judging by your code, you are only checking inside the character with a loop (you can get rid of the loop and replace it with a FindFirstChildOfClass), so it only is trying to find the tool that the player currently has equipped. You want to use findfirstchildofclass on the character to figure out if theyre holding something like a gun for example, and also the players backpack to get the rest of the tools they own
I see. I think instead of immediately directing to the ProximityPrompt after :WaitForChild() you should instead define Handle and then go to the proximity prompt.
Your script also is only checking the equipped item (not the backpack of stored items). I’m assuming this is intentional behavior because you said “the item the character holds”.
local Handle = tool:WaitForChild("Handle") -- find the handle
if Handle ~= nil then -- if the handle exists
local Prompt = Handle:WaitForChild("ProximityPrompt") -- find the prompt
if Prompt ~= nil then -- if the prompt exists
Prompt.HoldDuration = 5 -- change the property
end
end
yeah it works now, thank you all for the help! also could there be a way i can add a script in serverscriptservice that finds tools in workspace and removes them after a certain time?