When I change de parent of a pet with a local script the pet stop following the player in server
Client Side
Server Side
-- Follow Server Script
local Disabled = false
local Player = game.Players:FindFirstChild(script.Parent.Parent.Name)
if Player then
local Character = Player.Character or Player.CharacterAdded:Wait()
while true do
wait()
if Character.Health ~= 0 then
if not Disabled then
local Pos = script.Parent.Pos.Value
local BG = script.Parent.PrimaryPart.BodyGyro
local BP = script.Parent.PrimaryPart.BodyPosition
local d = Player.Character.HumanoidRootPart.Position.Y - script.Parent.PrimaryPart.Position.Y
BP.Position = (Player.Character.HumanoidRootPart.Position + Pos) - Vector3.new(0,Player.Character.HumanoidRootPart.Size.Y/2,0) + Vector3.new(0,script.Parent.PrimaryPart.Size.Y/2,0) + Vector3.new(0,game.ServerScriptService.globalPetFloat.Value,0)
if Player.Data.isWalking.Value == false then
BG.CFrame = CFrame.new(script.Parent.PrimaryPart.Position, Player.Character.HumanoidRootPart.Position - Vector3.new(0, d, 0))
else
BG.CFrame = Character.HumanoidRootPart.CFrame
end
else
script.Parent:Destroy()
break
end
end
end
end
-- Hide Pet Local Script
script.Parent.MouseEnter:Connect(function()
script.Parent:TweenSize(UDim2.new(0.150, 0, 0.112, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
end)
script.Parent.MouseButton1Down:Connect(function()
script.Parent:TweenSize(UDim2.new(0.140, 0, 0.102, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
wait(.3)
script.Parent.Visible = false
script.Parent.Parent.On_Hpets.Visible = true
local plr = game.Players.LocalPlayer
--ocal folder = workspace.PlayerPets:FindFirstChild(plr.Name)
for i,v in pairs(workspace.PlayerPets:GetChildren()) do
v.Parent = game.ReplicatedStorage.PlayerPets
end
script.Parent.MouseButton1Up:Connect(function()
script.Parent:TweenSize(UDim2.new(0.150, 0, 0.112, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
end)
end)
script.Parent.MouseLeave:Connect(function()
script.Parent:TweenSize(UDim2.new(0.156, 0, 0.118, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.1, true)
end)