local innocent = {} local players = game.Players:GetPlayers() _G.murderer = players[math.random(#players)].Name _G.sheriff = players[math.random(#players)].Name for i,v in pairs(players) do if v.Name ~= sheriff and v.Name ~= murderer then _G.table.insert(innocent, v.Name) end end print("MURDERER: "..murderer,"SHERIFF: "..sheriff, "INNOCENTS: "..table.concat(innocent,", "))
Ok this will pretty much just pick random murder, sheriff and make the rest innocents
while true do if _G.player.Name == _G.murder.Name then script.Parent.Text = "MURDERER" script.Parent.TextColor3 = Color3.new(255,0,0) elseif _G.player.Name == _G.sheriff.Name then script.Parent.Text = "SHERIFF" script.Parent.TextColor3 = Color3.new(0,0,255) elseif _G.player.Name == _G.innocent.Name then script.Parent.Text = "INNOCENT" script.Parent.TextColor3 = Color3.new(0,255,0) end end
This is in a GUI TextLabel, and I want it to check the other script to see if the player is murder, sheriff or innocent. Whatever they are, it chnages the text to their role.
So, I have tried using the _G. thingy to get the scripts to use each others code, but this dosent work. Anyone got an Idea of what I am doing wrong?
_G.innocent = {} local players = game.Players:GetPlayers() _G.murderer = players[math.random(#players)].Name _G.sheriff = players[math.random(#players)].Name for i,v in pairs(players) do if v.Name ~= _G.sheriff and v.Name ~= _G.murderer then table.insert(_G.innocent, v.Name) --_G. Is a global tag, so it shouldn't be before a function, but it has to be before the tag name. end end print("MURDERER: ".. _G.murderer,"SHERIFF: ".. _G.sheriff, "INNOCENTS: "..table.concat(_G.innocent,", "))
while true do wait() --You'll crash you game if you don't add that. if player.Name == _G.murder then --The value was already a string. And you don't have to put the global tag for the player's name. script.Parent.Text = "MURDERER" script.Parent.TextColor3 = Color3.new(255,0,0) elseif player.Name == _G.sheriff then script.Parent.Text = "SHERIFF" script.Parent.TextColor3 = Color3.new(0,0,255) elseif player.Name == _G.innocent then --Error might occur here because you're comparing a player's name to a table. script.Parent.Text = "INNOCENT" script.Parent.TextColor3 = Color3.new(0,255,0) end end