Ad
Log in to vote
0

Why can't I destroy the pet?

Asked by 15 days ago

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

Log in to vote
0
Answered by 15 days ago
Edited 15 days ago

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.

Ad

Answer this question