LOCAL SCRIPT

local PLAYER = game.Players.LocalPlayer
local PET = PLAYER:WaitForChild(“EQUIPPED_PET”, true)
local PETS_LIST = require(game.ReplicatedStorage.PETS_LIST)

local STEPPED = nil
local POS = nil
local GYR = nil

local function GET_PET(CHAR, NAME)
for _…


This content originally appeared on DEV Community and was authored by joinmoin0002

local PLAYER = game.Players.LocalPlayer
local PET = PLAYER:WaitForChild("EQUIPPED_PET", true)
local PETS_LIST = require(game.ReplicatedStorage.PETS_LIST)

local STEPPED = nil
local POS = nil
local GYR = nil

local function GET_PET(CHAR, NAME)
for _, v in pairs(CHAR:GetChildren()) do
if v:IsA("BasePart") and table.find(PETS_LIST, v.Name) then
if table.find(PETS_LIST, v.Name) then
return v
end
end
end
end

local function GET_MOVERS(PET)
for _, v in pairs(PET:GetChildren()) do
warn(v.ClassName)
if v:IsA("BodyPosition") then
POS = v
end
if v:IsA("BodyGyro") then
GYR = v
end
end

end

PET.Changed:Connect(function(NAME)
local PET = GET_PET(PLAYER.Character, NAME)
print(PET)
if PET ~= nil then
GET_MOVERS(PET)
print(POS, GYR)
if STEPPED then
STEPPED:Disconnect()
end

    STEPPED = game:GetService("RunService").Stepped:Connect(function()
        if PLAYER.Character.Humanoid.Health > 0 then
            local DEST = CFrame.new(PLAYER.Character.Head.CFrame * Vector3.new(1, 0, 2)).p
            local CF = PLAYER.Character.Head.CFrame

            POS.Position = DEST
            print(POS.Position)
            GYR.CFrame = CF
        else
            if STEPPED then
                STEPPED:Disconnect()
            end
            POS.MaxForce = Vector3.new(0, 0, 0)
            POS = nil
            GYR = nil
        end
    end)


end

end)

.


This content originally appeared on DEV Community and was authored by joinmoin0002


Print Share Comment Cite Upload Translate Updates
APA

joinmoin0002 | Sciencx (2021-10-10T15:51:15+00:00) LOCAL SCRIPT. Retrieved from https://www.scien.cx/2021/10/10/local-script/

MLA
" » LOCAL SCRIPT." joinmoin0002 | Sciencx - Sunday October 10, 2021, https://www.scien.cx/2021/10/10/local-script/
HARVARD
joinmoin0002 | Sciencx Sunday October 10, 2021 » LOCAL SCRIPT., viewed ,<https://www.scien.cx/2021/10/10/local-script/>
VANCOUVER
joinmoin0002 | Sciencx - » LOCAL SCRIPT. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/10/local-script/
CHICAGO
" » LOCAL SCRIPT." joinmoin0002 | Sciencx - Accessed . https://www.scien.cx/2021/10/10/local-script/
IEEE
" » LOCAL SCRIPT." joinmoin0002 | Sciencx [Online]. Available: https://www.scien.cx/2021/10/10/local-script/. [Accessed: ]
rf:citation
» LOCAL SCRIPT | joinmoin0002 | Sciencx | https://www.scien.cx/2021/10/10/local-script/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.