Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

For some reason this script is not working. Can someone help me out?

This script is supposed to be getting everyone on a team of green and putting there names in random slots in the scripts children named king. there are 5 string values named "King" and the output is saying "String expected" on line 7. Can someone help me?

print("Putting random slots for green") local labels={[1] = script.King} local count=1 wait(0.5) for _,v in pairs(game.Players:GetPlayers())do if v.TeamColor==BrickColor.new("Bright green")and labels[count]then labels[count].Value=v table.insert(labels,count,v.Name) count=count+1 print("Done putting slots for green") end end

1 answer

I don't think you can simply have script.King to be able to detect 5 StringValues. You may need to declare multiple times or change the name of 'King' to 'King1', 'King2' and so. I'm not sure what you're doing with declaring labels and count.

print("Putting random slots for green") 
local labels = {[1] = script.King} 
local count = 1 wait(0.5) 

for _,v in pairs(game.Players:GetPlayers())do 
	if v.TeamColor == BrickColor.new("Bright green") and labels[count] then 
		labels[count].Value = v table.insert(labels,count,v.Name) count = count+1 print("Done putting slots for green")
	end 
end

This discussion is preserved as it was. New answers, comments, and votes are closed.