Pet Body Position Doesn't follow right

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)
	

			
1 Like

You need to change the parent on the server. When you change the parent on the client it just does it on that players client which is why it works how intended on the client but to the server the parents of those pets didn’t change.

1 Like

But I want hide pets of all players only for the local player
When the local player hide pets his pets stop following in server and so all player saw his pets stoped

In that case, you need to change the transparency of the pets instead of changing the parent.

So my local script must change be transparency of all pets at 1 ?

Correct. Sorry for the late reply, you replied to your post not my comment so I didn’t get a notification.

1 Like