I am creating a script that will be able to be interacted with again once a tool has been deleted from workspace, but I cant seem to find anything related to it, and I don’t know how to do something like this.
Hello AimP0int,
Like slothfulGuy told you could use FindFirstChild, a example of this is:
local Tool = workspace:FindFirstChild("Tool") -- Will look for anything that is the children of workspace with the name Tool.
if not Tool then -- put here what you want if you can't find the children with the name Tool.
end
1 Like
It doesn’t seem to work for me, here’s the code I’m using.
local ProximityPrompt = script.Parent
local tool = game.ServerStorage.Tools["SCP-513"]
local sound = script.Parent.Parent.Take
local scp513 = workspace:FindFirstChild("SCP-513")
ProximityPrompt.Triggered:Connect(function(plr)
if ProximityPrompt.ActionText == "Take Item" then
sound:Play()
local klone = tool:clone()
wait(0.39)
if klone.Parent ~= plr.Backpack then
klone.Parent = plr.Backpack
script.Parent.Parent.Transparency = 1
script.Parent.Parent.CanCollide = false
ProximityPrompt.Enabled = false
else
if not scp513 then
script.Parent.Parent.Transparency = 0
script.Parent.Parent.CanCollide = true
ProximityPrompt.Enabled = true
end
end
end
end)
For me it is working, do you get any errors or what is happening?
I used this part of the code to test(in a script and localscript):
local scp513 = workspace:FindFirstChild("SCP-513")
if not scp513 then
print("Not scp513")
end
1 Like
You could use the ChildRemoving or DescendantRemoving event to indicate something has been removed/destroyed from whatever directory, e.g workspace.
workspace.DescendantRemoving:Connect(function(obj)
if obj.Name == "SCP-513" and obj:IsA("Tool") then
print('tool removed')
end
end)
2 Likes
When I unequip it, it prints tool removed, how can I make it wait a few seconds before doing this script?
wait(x) where x is the amount of seconds to pause the execution for