• Trying to get players SteamID and write it to a txt file
    2 replies, posted
Hello, i'm trying to get the SteamID of players who connect to the server and write it followed by a comma in a file called by the player's SteamID.txt but I get an error from the console [ERROR] lua/autorun/data.lua:8: attempt to index a string value with bad key ('Write' is not part of the string library)   1. error - [C]:-1    2. __index - lua/includes/extensions/string.lua:297     3. v - lua/autorun/data.lua:8      4. unknown - lua/includes/modules/hook.lua:84 Here is my code if file.Exists( "characters", "DATA" ) == false then     file.CreateDir( "characters" ) end hook.Add( "PlayerInitialSpawn", "Spawn", function( player )     steamid = player:SteamID()     file = steamid..".txt"     file.Write( "characters/"..steamid..".txt", steamid.."," ) end )
1. Use local when using variables (This will explain: Programming in Lua) 2. Don't use variables names that are used as a global GMod library (such as: file, player, etc.) Especially when they are not set as local.... 3. Use Player/SteamID64 instead of just SteamID
thanks, I didn't saw that I forgot the local before the variables :/
Sorry, you need to Log In to post a reply to this thread.