frriend
|
  |
| Joined: 07 Feb 2010 |
| Total Posts: 577 |
|
|
| 07 Oct 2015 10:13 PM |
So i have this code inside of a gui in every player.. (Public Script)
_G.alert = function(title, inform, plr) local player = game.Players:FindFirstChild(plr.Name) if player then script.Parent.Window.Alert.Text = title script.Parent.Window.Info.Text = inform local frame = player.PlayerGui.Alert.Window frame:TweenPosition(UDim2.new(0.5, -100, 0.5, -50), "Out", "Quad", 1) wait(4) frame:TweenPosition(UDim2.new(0.5, -100, -1, 0), "Out", "Quad", 1) wait(4) frame.Position = UDim2.new(0.5, -100, 1, 0) end end
and i call the function using this..
for _, player in ipairs(game.Players:GetPlayers()) do spawn(function() _G.alert("Supply Crates Dropping", "Supply crates have been dropped! Fight for them!", player)end) end
but for some reason, only a few players get the message, and others get the text from another message on another script..
Any help? I'm so lost on why this is happening.. Its my first time with global functions.
|
|
|
| Report Abuse |
|
|
frriend
|
  |
| Joined: 07 Feb 2010 |
| Total Posts: 577 |
|
|
| 07 Oct 2015 10:18 PM |
| I need urgent help. I don't have much time. |
|
|
| Report Abuse |
|
|
frriend
|
  |
| Joined: 07 Feb 2010 |
| Total Posts: 577 |
|
| |
|
frriend
|
  |
| Joined: 07 Feb 2010 |
| Total Posts: 577 |
|
| |
|
|
| 08 Oct 2015 05:41 PM |
Global functions are global functions for a reason, they are global.
When you put a global function inside of every player, it redefines the global function for EVERYONE in the game. That means, the newest person to join is the "player" variable.
So, when you run the script on everyone, that one person is getting the message because they have redefined the global function |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 08 Oct 2015 05:43 PM |
Incorrect term This is a function in a shared table
Red Blossoms |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2015 05:44 PM |
@ray, it's a function in a global table, but according to the wiki, that's what a global function is
it's either or http://wiki.roblox.com/index.php/Global_function |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 08 Oct 2015 05:46 PM |
Nope
A global function is a global variable:
x=function() print("hello") end
Meaning it is accessible in the global scope
Red Blossoms |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2015 05:49 PM |
According to the wiki, a function inside a global variable is a global function
so _G.variable = function() is a global function (because it is a function in a global variable) |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 08 Oct 2015 05:50 PM |
According to the Lua website
lua. org/pil /1.2.html
Red Blossoms |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2015 05:52 PM |
| I was talking about global as in the global table, not global scope of one script |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 08 Oct 2015 05:55 PM |
Well now you know to refer to it as a shared function
Red Blossoms |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 08 Oct 2015 06:37 PM |
"According to the Lua website
lua. org/pil /1.2.html"
But Roblox Lua is modified differently. |
|
|
| Report Abuse |
|
|