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

How to make scripts read other scripts?

		local sheriff   
		local murderer
		local innocent  = {}

		local players = game.Players:GetPlayers()
		murderer = players[math.random(#players)].Name
		sheriff = players[math.random(#players)].Name
		for i,v in pairs(players) do 
    		if v.Name ~= sheriff and v.Name ~= murderer then 
        		table.insert(innocent, v.Name)
    		end
		end

		print("MURDERER: "..murderer,"SHERIFF: "..sheriff, "INNOCENTS: "..table.concat(innocent,", "))

Ok, so I have tried the wiki, for about 4 hours, with no luck. This script will pick 1 murder, 1 sheriff, and the rest innocent, but I need another script within a gui needs to read this and check what role a player has, so it tells the players what role they have. Anyone have a solution

3 answers

Roblox Roblox locked the source property of scripts, my best solution I could give is using the _G. Tag to make the innocent table and murder/sheriff tags a global value to be used throughout the game.

1 comment

0

so how would the other script check the players role?

The script would receive all global variables. If you want a Global function, go here. If you just want a variable? Go here.

So, in your case, you'd put _G.Players or _G.murderer.

Also, remove line 1 and 2.

~ Thank me by accepting this answer.

4 comments

0

So _G.murder in its variable, then in the other script I type if player = murderer then??

0

In the other script, you'd type if _G.player.Name == _G.murder.Name then

0

But so where does the _G. go in the script above?

0

Just use _G. for any variable you have that you want to access in the script. So, right now, I can probably tell you want players, murderer, and Sheriff. So, put _G. before every variable (no space).

Or use the solution I told you in the other post you made. No double posts please.

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