I made an inventory GUI and each time u left click a certain text button a pet appears and follows you.Now i want that pet deleted when player right clicks the same text button how do i do that? I have already tried something but it didn't work,here is the whole script(the upper part works)
local target = game.ReplicatedStorage.AlphaPet script.Parent.MouseButton1Click:connect(function() if game.Players.LocalPlayer.Character:FindFirstChild("AlphaPet")== nil then local pet = target:Clone() pet.Parent = game.Players.LocalPlayer.Character pet.LocalScript.Disabled = false end end) script.Parent.MouseButton2Click:connect(function() if game.Players.LocalPlayer.Character:FindFirstChild("AlphaPet")== true then local pet = target:Clone() pet.Parent = game.ServerStorage.Junk pet.LocalScript.Disabled = true end end)
target = game.ReplicatedStorage.AlphaPet script.Parent.MouseButton1Click:connect(function() if game.Players.LocalPlayer.Character:FindFirstChild("AlphaPet")== nil then local pet = target:Clone() pet.Parent = game.Players.LocalPlayer.Character pet.LocalScript.Disabled = false end end) script.Parent.MouseButton2Click:connect(function() if game.Players.LocalPlayer.Character:FindFirstChild("AlphaPet")== true then local pet = target:Clone() pet:Destroy() -- COMPLETELY removes it pet.LocalScript.Disabled = true end end)
Stop using local variables. THEY DO NOT WORK.