Hey. I made a pet, which works well. But, since I saw when I use a while loop the pet is slowly following you, I thought of an idea. To basically, fire a remote to all clients and set the position using RunService, since RunService events fire way faster than while loops, and it will look smooth and clean. But, it only fires on your client, basically, only you can see it. Here are my scripts, what can I do:
Server Script:
local pet = script.Parent
local function change_Poistion()
if script.Parent.Parent.Humanoid ~= nil then
script.Parent.RemoteEvent:FireAllClients()
end
end
while wait() do
if script.Parent.Parent:FindFirstChild("Humanoid") then
change_Poistion()
end
end
Local Script:
local pet = script.Parent
local function change_Poistion()
if script.Parent.Parent.Humanoid ~= nil then
local runService = game:GetService("RunService")
runService.RenderStepped:Connect(function()
pet.Position = Vector3.new(script.Parent.Parent.LowerTorso.Position.X - 5, script.Parent.Parent.LeftLowerLeg.Position.Y + 0.325, script.Parent.Parent.LowerTorso.Position.Z - 3)
pet.Orientation = Vector3.new(pet.Orientation.X, script.Parent.Parent.LowerTorso.Orientation.Y - (-46.22 - 38.19), pet.Orientation.Z)
end)
end
end
script.Parent.RemoteEvent.OnClientEvent:Connect(change_Poistion)