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

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

Asked by 7 years ago

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.

0
Do you know how to script? GingeyLol 338 — 7y
0
Very little to none Faze360noscope1017 0 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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

Ad

Answer this question