So I’m tryna make something where a dragon npc follows around a player, like a pet almost you’d see in pet sim x.
It works and everything but when there is multiple players with multiple dragons following people around, it for some reason slows down the game by alot. For example a timer, it would slow down the timer by 2x and basically break the whole game.
How would I get around this?
local Players = game:GetService("Players")
while true do
if script.Parent.Player.Value == nil then
--no player to follow
else
local char = script.Parent.Player.Value
local plr = Players:GetPlayerFromCharacter(char)
if plr:WaitForChild("PlayerData").Sitting.Value == false then
script.Parent.Humanoid:MoveTo(char:WaitForChild("HumanoidRootPart").Position + Vector3.new(0,0,5))
end
end
wait(0.1)
end
the Player.Value thingy is a object value in the dragon model itself that gets the player, once the player is assigned to that dragon.