Is bad idea to use tween:play() in renderstepped?
i try to just write play outside in
while true do wait(1)
…
end
but i will hope i can just do renderstepped but idk is okay
local RS = game:GetService("ReplicatedStorage")
local removeEv = RS:WaitForChild("Remote"):WaitForChild("PetsEquip")
local fullCircle = 2 * math.pi
local conn = {}
function stuff()
for i, player in pairs(game.Players:GetChildren()) do
local PlayerEquip = player.Character:WaitForChild(player.Name.." Pets")
local hr = player.character:WaitForChild("Humanoid")
local hrp = player.character:WaitForChild("HumanoidRootPart")
local pets = {}
for _, pet in pairs(PlayerEquip:GetChildren()) do
table.insert(pets, pet)
end
local num = 3
local radius = 5
local tween
local play = false
if conn[player] then conn[player]:Disconnect() print("stop") end
conn[player] = game:GetService("RunService").RenderStepped:Connect(function()
for i, pet in pairs(pets) do
if i > num then
radius += 1
num += 3
end
local function getXAndZPositions(angle)
local x = math.cos(angle) * radius
local z = math.sin(angle) * radius
return x, z
end
local angle = i * (fullCircle / #pets)
local x, z = getXAndZPositions(angle)
local position = (hrp.CFrame * CFrame.new(x, 0, z)).p
local lookAt = Vector3.new(hrp.Rotation.X, 0 ,0)
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
1,
false,
0
)
for i, v in pairs(pet:GetChildren()) do
tween = TweenService:Create(pet[v.Name], tweenInfo, {Position = position})
tween:Play()
end
-- pet.PrimaryPart.CFrame = CFrame.new(position, lookAt)
end
end)
end
end
removeEv.OnClientEvent:Connect(stuff)