So, I have been working on a pet script for my game. I have completed the gui, and all I need now is to work on the equip/unequip pet bit. Currently, if you own the gamepass the pet will appear next to you, because there is more than one pet, to prevent the pets merging and looking horrible I am trying to create an equip/unequip feature.

This is the script that creates the orb:

game.Players.LocalPlayer:WaitForChild("MyClientEvent").OnClientEvent:connect(functi		on()
local p = game.Players.LocalPlayer
local char = p.Character or p.CharacterAdded:wait()

local orb = Instance.new('Part', char)
orb.Name = 'Orb'
orb.CanCollide = false

local mesh = Instance.new("SpecialMesh",orb)
mesh.MeshType = "FileMesh"
mesh.TextureId = "rbxassetid://329865098"
mesh.MeshId = "rbxassetid://329864728"
mesh.Scale = Vector3.new(0.5,0.5,0.5)

local body = Instance.new('BodyPosition', orb)
local gyro = Instance.new('BodyGyro', orb)
gyro.maxTorque = Vector3.new(1,1,1)/0

while wait() do
body.Position = char.Head.CFrame:pointToWorldSpace(Vector3.new(2,1,0))
gyro.cframe = CFrame.new(Vector3.new(), char.Head.CFrame.lookVector)
end

while wait() do
body.Position = char.Head.Position + Vector3.new(2,1,0)
end

body.Position = char.Head.CFrame:pointToWorldSpace(Vector3.new(2,1,0))

end)

I want to be able to make this orb go away, and come back when a button is pressed. Can someone guide me as to what I have to do? I am using an event that when fired will make the pet equip/unequip.

Here is the event script in the button that will be pressed to unequip/equip the pet. By default if you own the gamepass it is automatically equiped.

game.Players.LocalPlayer:WaitForChild("PandaGUI").OnClientEvent:connect(function()
script.Parent.Image = "rbxgameasset://Images/PandaGreen"
script.Parent.Script:Destroy()
script.Parent.MouseButton1Down:connect(function()
	
end)
end)

I need help as to what to put into the "MouseDown" bit to make the orb disappear once clicked, then when clicked again to re-appear. I think its something to do with transparency.

Thanks.

3 comments

0

sorry its a bit lengthy

0

You should use 1waffle1's indent plugin...

0

Oh, I think I answered it! Let me double check.