Ok so I have a humanoid model in workspace called "Noob" and have a script that plays an animation then destroys it when they die, Problem is that the client can't seem to get rid of the model and manually deleting it seems to just deselect it. The script is here:
local walk = script.Parent.Humanoid:LoadAnimation(script.Walk)
local idle = script.Parent.Humanoid:LoadAnimation(script.Idle)
local attack = script.Parent.Humanoid:LoadAnimation(script.Attack)
local ded = script.Parent.Humanoid:LoadAnimation(script.Death)
local running = script.Running
script.Parent.Humanoid.Running:Connect(function(speed)
if speed <= 0 then
running.Value = true -- I have no clue why but this is reversed :/
else
running.Value = false
end
end)
running.Changed:Connect(function()
if running.Value == true and script.Parent.Humanoid.Health > 0 then
idle:Play()
walk:Stop()
elseif script.Parent.Humanoid.Health > 0 then
walk:Play()
idle:Stop()
end
end)
script.Parent.Attack.Event:Connect(function(target)
if script.Parent.Humanoid.Health > 0 then
attack:Play()
script.Parent.HumanoidRootPart.CFrame = CFrame.new(script.Parent.HumanoidRootPart.Position,target.Position*Vector3.new(1,0,1) + script.Parent.HumanoidRootPart.Position*Vector3.new(0,1,0))
end
end)
script.Parent.Humanoid.Died:Connect(function()
walk:Stop()
idle:Stop()
attack:Stop()
script.Parent.Humanoid.WalkSpeed = 0
script.Parent.HumanoidRootPart.Anchored = true
ded:Play()
spawn(function()
wait(0.8)
script.Parent:Destroy()
end)
end)

2 comments
You should really use a RemoteEvent and let the server handle destroying the part. Destroying a part via the client will not save to the server.
The problem is that it destroys on the server but not the client