-- arguments --------------------------------------- local threadSleepTime = ... if threadSleepTime==nil then threadSleepTime = 15 end -- globals ----------------------------------------- client = game:GetService("NetworkClient") visit = game:GetService("Visit") -- functions --------------------------------------- function setMessage(message) -- todo: animated "..." game:SetMessage(message) end function showErrorWindow(message) game:SetMessage(message) end function reportError(err) print("***ERROR*** " .. err) visit:SetUploadUrl("") client:Disconnect() wait(4) showErrorWindow("Error: " .. err) game:HttpPost("http://www.roblox.com/Error/Lua.ashx?", "Join.lua: " .. err) end -- called when the client connection closes function onDisconnection(peer, lostConnection) if lostConnection then showErrorWindow("You have lost the connection to the game") else showErrorWindow("You have disconnected from the game") end end function requestCharacter(replicator) -- prepare code for when the Character appears local connection connection = player.Changed:connect(function (property) if property=="Character" then game:ClearMessage() connection:disconnect() end end) setMessage("Requesting character") -- a little delay to give you a chance to prepare: wait(1.5) local success, err = pcall(function() replicator:RequestCharacter() setMessage("Waiting for character") end) if not success then reportError(err) return end end -- called when the client connection is established function onConnectionAccepted(url, replicator) local waitingForMarker = true local success, err = pcall(function() setMessage("Setting ping") visit:SetPing("http://www.roblox.com/Game/ClientPresence.ashx?Username=Player&PlaceID=0", 300) setMessage("Logging stats") game:HttpGet("http://www.roblox.com/Game/Statistics.ashx?SessionID=&TypeID=5&UserID=0&AssociatedUserID=0&AssociatedPlaceID=0") game:SetMessageBrickCount() replicator.Disconnection:connect(onDisconnection) -- Wait for a marker to return before creating the Player local marker = replicator:SendMarker() marker.Received:connect(function() waitingForMarker = false requestCharacter(replicator) end) end) if not success then reportError(err) return end -- TODO: report marker progress while waitingForMarker do workspace:ZoomToExtents() wait(0.5) end end -- called when the client connection is rejected function onConnectionRejected() showErrorWindow("Please upgrade ROBLOX") game:HttpPost("http://www.roblox.com/Error/Lua.ashx?", "Join.lua: Wrong version of ROBLOX") end -- called when the client connection fails function onConnectionFailed() showErrorWindow("Failed to connect to the Game") game:HttpPost("http://www.roblox.com/Error/Lua.ashx?", "Join.lua: ConnectionFailed") end function onPlayerIdled(time) if time>30*60 then showErrorWindow(string.format("You were disconnected for being idle %d minutes", time/60)) client:Disconnect() end end -- main ------------------------------------------------------------ local success, err = pcall(function() setMessage("Creating Player") player = game:GetService("Players"):CreateLocalPlayer(0) player:SetUnder13(false) player:SetSuperSafeChat(false) player.Idled:connect(onPlayerIdled) player.Name = [======[Player]======] player.CharacterAppearance = "http://www.roblox.com/Data/Get.ashx?hash=84352068ac4be2ca18456a85ff2e546c;http://www.roblox.com/Data/AssetFetch.ashx?hash=0b16797bf15b7ee6c208b3f73face654&isapproved=true" visit:SetUploadUrl("") setMessage("Connecting to Server") client.ConnectionAccepted:connect(onConnectionAccepted) client.ConnectionRejected:connect(onConnectionRejected) client.ConnectionFailed:connect(onConnectionFailed) client:Connect("localhost", 1234, 53639, threadSleepTime) end) if not success then reportError(err) end