|
| 27 Dec 2015 02:25 PM |
Hey.
I'm interested in knowing whether or not when I create a StringValue variable in a Script, and I alter its value inside of a function, can a different function use that new altered value?
Thanks! |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Dec 2015 02:33 PM |
Alright, and I'm also wanting a certain part to return to a position when a player leaves the game. Is there any way to check that? I have it so the function is called when the PlayerRemoving, but from what I understand, that doesn't specify a player that leaves. Could you help me with that?
I thought I could use the StringValue to store the name of a player and compare it to each Player that leaves to check for a match, but I'm unsure how to do so. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 27 Dec 2015 02:34 PM |
game.Players.PlayerRemoving:connect(function(player) print("A player has left: " .. player.Name) end) |
|
|
| Report Abuse |
|
|
hkep
|
  |
| Joined: 19 Jul 2014 |
| Total Posts: 550 |
|
|
| 27 Dec 2015 03:19 PM |
local JoinedPlayers = {};
game.Players.PlayerAdded:connect(function(Player) table.insert(JoinedPlayers,Player.Name); end);
game.Players.PlayerRemoving:connect(function(Player) for i=1,#JoinedPlayers,1 do local xPlayer = JoinedPlayers[i]; if xPlayer == Player.Name then print("Player: "..xPlayer.." is has joined and left!"); table.remove(JoinedPlayers,i); break; end; end; end); |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 08:59 PM |
@Soybeen Yes, I'm familiar with that example, but I don't really see how that helps with my current problem.
@hkep This code seems to be creating a table, adding joined players to it, and then checking for a specific one (if it finds that player, it prints out), then cancels off everything else. Thank you for this, I'll try to implement this and mold to see if I can fit it to my needs. Thank you, and I'll get back to you with any of my problems that I encounter. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 09:03 PM |
| Is there a way I might be able to simply check the player's list and wait until that check returns false, then execute my code, or is it necessary that I have to create a table and record it myself? |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 27 Dec 2015 09:42 PM |
| David, the example I posted allows you to tell which player has left. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 10:26 PM |
@Soybeen Oh, yes. Thank you for that. It, along with what hkep provided, I was able to work my way to a working solution. So thanks again! |
|
|
| Report Abuse |
|
|
|
| 28 Dec 2015 12:02 AM |
Well, It seems I have another issue going on. After a few tests, I am unable to change the properties of "buttonHead". Could anyone pass by an idea to find why this isn't working? Thanks.
Code Below, can provide more if needed.
function buttonReturn(player) if (player.Name == playerName.Value) then buttonHead.CanCollide = true buttonHead.Transparency = 0 end end
game.Players.PlayerRemoving:connect(buttonReturn) |
|
|
| Report Abuse |
|
|