whenever i click on a part after i destroyed another part i get the error 17:22:30.359 - ScreenGui is not a valid member of UnionOperation
17:22:30.359 - Stack Begin
17:22:30.360 - Script 'Players.world_kiIIer.Backpack.Tool.LocalScript', Line 7
17:22:30.360 - Stack End
this is my tool script(local script ofcourse)
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
script.Parent.Activated:Connect(function()
mouse.Button1Down:connect(function()
if not mouse.Target then return end
mouse.Target.ScreenGui.Parent = plr.PlayerGui
end)
end)
this is my part script also a local script
debounce = false
script.Parent.MouseButton1Click:Connect(function()
if not debounce then
debounce = true
script.Parent.BackgroundColor3 = Color3.new(255, 0, 0)
game.Workspace.ores.Modelore.ironore3.Health.Value = game.Workspace.ores.Modelore.ironore3.Health.Value - 25
wait(1)
script.Parent.BackgroundColor3 = Color3.new(0, 0, 255)
debounce = false
end
if game.Workspace.ores.Modelore.ironore3.Health.Value == 0 then
game.Workspace.ores.Modelore.ironore3.Parent = script.Parent.Parent.Parent.Parent.Backpack
script.Parent.Parent:Destroy()
end
end)
after one part has been destroyed nothing happens but when i click on another part i get the error, why? and what does it mean

1 comment
i solved it myself, in the tool script i needed to see first if the mouse target had a child named ScreenGui and if so do what i wanted it to do