Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can't I destroy the pet?

Asked by
VipDanT 10
1 year 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
VAnkata20 135
1 year ago
Edited 1 year 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