Unable to assign property Position. Vector3 expected, got Instance [Random Spawn System]

  1. What do you want to achieve?
    Oh it’s probably easy to fix, all I need is a line that includes the vector of the random spawns.

  2. What is the issue?
    “Unable to assign property Position. Vector3 expected, got Instance”, Instance referring to the actual spawnLocation, when I want to use their position instead of the actual spawnLocation in a folder in workspace.

My server script: Everything works flawlessly except that line of code cuz I am not really good yet with math.random nor mathematical usage.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(model)
	
	game.ReplicatedStorage.SetSpawn.OnServerEvent:Connect(function()
	
			--player.RespawnLocation = game.Workspace.SpawnLocation1 
			local hirp = model:WaitForChild("HumanoidRootPart")

			hirp.Position = game.Workspace.SpawnL:GetChildren()[math.random(1, #game.Workspace.SpawnL:GetChildren())]
			print("worked")
			
		end)
	end)
end)

you forgot to index .Position property at the end

local Spawns = game.Workspace.SpawnL:GetChildren()
hirp.Position = Spawns[math.random(1, #Spawns)].Position

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.