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

Does anyone know how to make a pet game pass that you can equip or unequip?

I need help with scripting a game pass where you can buy a pet that follows you,and that you can equip/unequip.If someone could help me that would be great.thank you.

2 comments

0

Do you know how to script?

0

Very little to none

1 answer

Sorry i don't know how to script a gamepass but I can give a scrip that will allow your pet to follow anyone who is in range :-

local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")

function findNearestHead(pos)
	local list = game.Workspace:children()
	local torso = nil
	local dist = 25
	local temp = nil
	local human = nil
	local temp2 = nil
	for x = 1, #list do
		temp2 = list[x]
		if (temp2.className == "Model") and (temp2 ~= script.Parent) then
			temp = temp2:findFirstChild("Head")
			human = temp2:findFirstChild("Humanoid")
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
				if (temp.Position - pos).magnitude < dist then
					Head = temp
					dist = (temp.Position - pos).magnitude
				end
			end
		end
	end
	return Head
end

while true do
	wait(0.1)
	local target = findNearestHead(script.Parent.Head.Position)
	if target ~= nil then
		script.Parent.Humanoid:MoveTo(target.Position, target)
	end
end 

And here is the respawn script:-

name="Humanoid"
local waittime = 1 --Set amount of time to wait before respawn
robo=script.Parent:clone()

while true do
	wait(waittime)
	if script.Parent.Humanoid.Health<1 then
		robot=robo:clone()
		robot.Parent=script.Parent.Parent
		robot:makeJoints()
		script.Parent:remove()
	end
end

hope it help, sorry I am new to scripting so i don't know to program a gamepass

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