generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: StringValue Question

Previous Thread :: Next Thread 
DavidNate1 is not online. DavidNate1
Joined: 16 Jun 2008
Total Posts: 100
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
AdvancedObjects is not online. AdvancedObjects
Joined: 11 Dec 2012
Total Posts: 3354
27 Dec 2015 02:28 PM
Yes.
Report Abuse
DavidNate1 is not online. DavidNate1
Joined: 16 Jun 2008
Total Posts: 100
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 is not online. 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 is not online. 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
DavidNate1 is not online. DavidNate1
Joined: 16 Jun 2008
Total Posts: 100
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
DavidNate1 is not online. DavidNate1
Joined: 16 Jun 2008
Total Posts: 100
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 is not online. 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
DavidNate1 is not online. DavidNate1
Joined: 16 Jun 2008
Total Posts: 100
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
DavidNate1 is not online. DavidNate1
Joined: 16 Jun 2008
Total Posts: 100
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image