Ok, so I have a script in Workspace that jhas this text:
h=Instance.new("Hint") h.Parent=game.Workspace while wait(1) do h=Instance.new("Hint") h.Parent=game.Workspace script.StarterMusic:Play() --variables h.Text="" --round starts if game.Players.NumPlayers<=0 then while game.Players.NumPlayers<=0 do wait(1) h.Text="Waiting for 2 players..." end else i=5 while wait(1) and i>0 do h.Text=i.." seconds until the round starts!" i=i-1 end h.Text="Choosing a random map..." local maps = game.ServerStorage["Maps"]:GetChildren() wait(3) map = maps[math.random(1, #maps)] h.Text=map wait(1) end end
What happens is the script freezes after it chooses the map. The only error I ever get is 06:09:49.080 - String expected
. I think it's the way I' choosing the map. If so, how do I fix it? If not, what is it? Please help. Thanx.
-ds
You're setting the Text
property to a userdata on line 30
, but the Text Property takes in strings!
Just index the Name
Property of 'map' on line 30. This way, you will be providing a string of the map's name.
--No need to create a hint up here, as you do inside the while loop while wait(1) do local h = Instance.new("Hint",workspace) script.StarterMusic:Play() --Check if it's less than 2, since you want there to be 2 players. if game.Players.NumPlayers < 2 then wait(1) h.Text = "Waiting for 2 players..." else --Just use a for loop!(: for i = 5,1,-1 do wait(1) h.Text = i.." seconds until the round starts!" end h.Text = "Choosing a random map..." local maps = game.ServerStorage["Maps"]:GetChildren() --Choose the map before you wait.. just more efficient. local map = maps[math.random(1, #maps)] wait(3) h.Text = map.Name end end
It says string expected, because of line 30. You made the mistake of trying to display a message, of the physical model! Instead, put h.Text = map.Name
, which is the string that it's asking for!