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
joinmoin0002 | Sciencx (2021-10-10T15:51:15+00:00) LOCAL SCRIPT. Retrieved from 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.