So In my game you can collect stars, the stars are located in a model that is spawned in the workspace from replicated storage. Stars are local and there are about 20 stars in the whole game.
This is the script that gives the player the 1 point for collecting a star. It gets the children of the model and if the player touches the Part he gets a point. It works fine until I try to make the stars spin around. It only spins 1 star and all the other stars stay still.
local Stars = workspace.Stars:GetChildren()
local player = game.Players.LocalPlayer
for i, v in pairs(Stars) do
if v.Name == "Star" then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then
if hit.Parent.Name == player.Name then
game.ReplicatedStorage.StarsEvent:Fire()
v:Destroy()
end
end
end)
end
while true do
v.CFrame = v.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 5)
wait() -- This part only spins 1 star not all 20 of them.
end
end

1 comment
Thats because when it gets to 1 star it makes a while true do and then never gets out of it.