Removing tag from specific object

So i’m trying to destroy an object after it hits 0 health and the destroying works, but then i get a error saying “Health is not a valid member of Model tree”. So i tried removing the tag from the object after it gets destroyed and also setting the object to nil. But nothing seems to work.
Here is my script

local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvents.BreakableHit
local RemoteEvent2 = game:GetService("ReplicatedStorage").RemoteEvents.BreakableDestroy
--Services--
local TweenService = game:GetService("TweenService")
local CollectionService = game:GetService("CollectionService")
local BreakableTag = CollectionService:GetTagged("BreakableRock")
--Tweening--
local Info = TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0 ,true)
--Main function
RemoteEvent.OnServerEvent:Connect(function(player, breakable)
	--[[local Params = {Size = breakable.Scale - Vector3.new(1, 1, 1)}
	local Tween = TweenService:Create(breakable, Info, Params)
	Tween:Play()]]--
end)

RemoteEvent2.OnServerEvent:Connect(function(player, breakable)
	breakable:Destroy()
	breakable = nil
	breakable:RemoveTag("Breakable")
end)

Any help will be appreciated!

1 Like

did you try removing the tag before it gets destroyed? I believe you can’t do anything to the object after it’s destroyed

Looks like i get the error even when removing the tag before destroying the tree

Nevermind i found out that i can just use :Remove() instead of :Destroy()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.