Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why can't I destroy the pet?

I'm working on a simulator Link btw: https://web.roblox.com/games/9952086550/Donut-Eating-Simulator And this destroy pet doesn't work. Can someone please explain this? Here's the code: game.ReplicatedStorage.Remotes.UnequipPet.OnServerEvent:Connect(function(player, pet) if player.Character.Humanoid.Health ~= 0 then player.Character:FindFirstChild(pet):Destory(pet) end end)

Other part of code:

script.Parent.MouseButton1Click:Connect(function() if script.Parent.Text == "Equip" or script.Parent.Text == "Buy" then local result = game.ReplicatedStorage.RemoteFunctions.EquipPet:InvokeServer(script.Parent.Parent.Name) if result == "Bought" then script.Parent.Text = "Equipped" script.Parent.Text = "Unequip" elseif result == "Not enough coins" then script.Parent.Text = "Not enough Eaten" wait(1) script.Parent.Text = "Buy" elseif result == "Unequip" then script.Parent.Text = "Unequip" end elseif script.Parent.Text == "Unequip" then game.ReplicatedStorage.Remotes.UnequipPet:FireServer(script.Parent.Parent.Name) end end)

1 answer

The replicated storage script should be like that:

game.ReplicatedStorage.Remotes.UnequipPet.OnServerEvent:Connect(function(player, pet) 
	if player.Character.Humanoid.Health ~= 0 then 
		player.Character:FindFirstChild(pet):Destroy() 
	end 
end)

the Destroy() function dosen't accept arguments. its a void function (which mean nothing goes in and nothing goes out) if there is another problem feel free to tell me.

This discussion is preserved as it was. New answers, comments, and votes are closed.