Sorry if the title made no sense, english is not my native language.
What I'm doing is, I have a Model on Workspace called Factories, and inside, there's 8 models that are called Factory. I want to loop through each one, get the IntValue and StringValue from them, and depending on the StringValue value, assign the Factory IntValue to the player who just joined.
Workspace > Factories > Factory > FactoryNumber and OwnerName
this is my script so far, and it's not working, no errors are thrown on the console:
EDIT: it is inside the function that is connected to the PlayerAdded event.
for _,factory in pairs(game.Workspace.Factories:GetChildren()) do local isOwnedBy = factory.OwnerName local factoryNumber = factory.FactoryNumber local spawnPos = factory.SpawnPoint.Position local playerModel = Workspace:FindFirstChild(player.Name) if isOwnedBy.Value == "" and player.FactoryNumber.Value == 0 then player.FactoryNumber.Value = factoryNumber.Value isOwnedBy.Value = player.Name if playerModel:IsA("Model") then playerModel.Character.Torso.CFrame = spawnPos end end end
Is there something wrong with my script?