Hello there! I’ve a script that is a event listener. It works all good but there is a line that doesn’t work properly.
ReplicatedStorage:WaitForChild("Remotes").AppleEvent:FindFirstChild("PlayerHealthGain").OnServerEvent:Connect(function(player)
if not debounce then
debounce = true
player.Character:WaitForChild("Humanoid").MaxHealth = player.Character:WaitForChild("Humanoid").MaxHealth + 5
player.Character:WaitForChild("Humanoid").Health = player.Character:WaitForChild("Humanoid").Health + 1
local Apple = player.Character:FindFirstChild("Apple") or player.Backpack:FindFirstChild("Apple") or player.StarterGear:FindFirstChild("Apple")
if Apple then
Apple:Destroy()
end
wait(1)
debounce = false
end
end)
If I remove player.StarterGear:FindFirstChild(“Apple”), then it will work but why? I want it to get destroyed from the StarterGear as well.