Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
0
Answered by
Dummiez 360 Moderation Voter
10 years ago

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
Ad

Answer this question