i have a breaking system which detects if player have a tool or not using string.name, but when i use it, it skipped straight to the cloning, heres the script:
wait()
local Stone = script.Parent.Value.Value
a = true
hasTool = false
script.Parent.At.Break.Triggered:Connect(function(plr)
if Stone ~= 0 then
if a then
a = false
Stone = Stone - 1
script.Parent.Parent.Thing.Transparency = script.Parent.Parent.Thing.Transparency + 0.25
script.Parent.Parent.Thing2.Transparency = script.Parent.Parent.Thing2.Transparency + 0.25
script.Parent.Parent.Thing3.Transparency = script.Parent.Parent.Thing3.Transparency + 0.25
script.Parent.Parent.Thing4.Transparency = script.Parent.Parent.Thing4.Transparency + 0.25
script.Parent.Parent.Thing5.Transparency = script.Parent.Parent.Thing5.Transparency + 0.25
wait(1)
a = true
end
end
if Stone == 0 then
for i, v in pairs(plr.Backpack:GetChildren()) do
if string.match(v.Name, "Table") and v:IsA("Tool") then
hasTool = true-- new here
plr.Resources.Table.Value = plr.Resources.Table.Value + 1
script.Parent.At.Break:Destroy()
script.Parent.At.Table:Destroy()
script.Parent.Parent:Destroy()
end
end
-- For player's character
if plr.Character then
for i, v in pairs(plr.Character:GetChildren()) do
if string.match(v.Name, "Table") and v:IsA("Tool") then
hasTool = true-- new here
plr.Resources.Table.Value = plr.Resources.Table.Value + 1
script.Parent.At.Break:Destroy()
script.Parent.At.Table:Destroy()
script.Parent.Parent:Destroy()
-- the player has the Wood tool
end
end
end
if hasTool == false then
wait()
local clone = game.ReplicatedStorage:WaitForChild("Crafting table"):Clone()
clone.Parent = plr.Backpack
plr.Resources.Table.Value = plr.Resources.Table.Value + 1
script.Parent.At.Break:Destroy()
script.Parent.At.Table:Destroy()
script.Parent.Parent:Destroy()
end
end
end)