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!