Answered by
4 years ago Edited 4 years ago
Try this (script to put in ServerScriptService)
001 | [ "DoMessages?" ] = true ; |
002 | [ "IsAnObby?" ] = false ; |
013 | [ "BestFriends?" ] = false ; |
014 | [ "Friends?" ] = false ; |
015 | [ "OwnerOnly?" ] = false ; |
018 | [ "GamepassId" ] = 000000 |
029 | debrisS, playerS, datastoreS, gamepassS, marketS = |
030 | game:GetService( "Debris" ), |
031 | game:GetService( "Players" ), |
032 | game:GetService( "DataStoreService" ), |
033 | game:GetService( "GamePassService" ), |
034 | game:GetService( "MarketplaceService" ) |
036 | function passedPlayer(p, isLeaving) |
037 | print (p.Name.. " has passed" ) |
038 | local function sendMessage(txt) |
039 | if gameStats [ "DoMessages?" ] then |
040 | local message = Instance.new( "Message" , p.PlayerGui) |
042 | debrisS:AddItem(message, 2 ) |
047 | local cDatastore, statStorage = |
048 | datastoreS:GetDataStore(p.Name.. "Stats" ), |
049 | p:WaitForChild( "leaderstats" ):GetChildren() |
050 | for i = 1 , #statStorage do |
051 | cDatastore:SetAsync(statStorage [ i ] .Name, statStorage [ i ] .Value) |
053 | sendMessage( "Your stats have been saved." ) |
056 | local cDatastore, stats = |
057 | datastoreS:GetDataStore(p.Name.. "Stats" ), |
058 | p:FindFirstChild( "leaderstats" ):GetChildren() |
060 | stats [ i ] .Value = cDatastore:GetAsync(stats [ i ] .Name) |
062 | sendMessage( "Your stats have been loaded." ) |
064 | local chatted = function (c) |
066 | for i, v in pairs (gameStats [ "DoChat?" ] [ "Keywords" ] ) do |
076 | if gameStats [ "DoChat?" ] [ "DoIt?" ] then |
077 | p [ "Chatted" ] :connect(chatted) |
082 | function passTest(p, isLeaving) |
083 | print ( "Test starting" ) |
084 | if gameStats [ "IsAnObby?" ] then |
085 | local cAdded = function (c) |
086 | p:LoadCharacter( true ) |
088 | p [ "CharacterAdded" ] :connect(cAdded) |
090 | if gameStats.saveType [ "Normal?" ] then |
091 | passedPlayer(p, isLeaving) |
093 | if gameStats.saveType [ "SavingList?" ] [ "DoIt?" ] then |
094 | for i, v in pairs (gameStats.saveType [ "SavingList?" ] .theList) do |
095 | if (p.Name = = v) then |
096 | passedPlayer(p, isLeaving) |
099 | elseif gameStats.saveType [ "BestFriends?" ] then |
100 | if p:IsBestFriendsWith(game.CreatorId) then |
101 | passedPlayer(p, isLeaving) |
103 | elseif gameStats.saveType [ "Friends?" ] then |
104 | if p:IsFriendsWith(game.CreatorId) then |
105 | passedPlayer(p, isLeaving) |
107 | elseif gameStats.saveType [ "OwnerOnly?" ] then |
108 | if (p.userId = = game.CreatorId) then |
109 | passedPlayer(p, isLeaving) |
111 | elseif gameStats.saveType [ "Gamepass?" ] [ "DoIt?" ] then |
112 | if p:PlayerHasPass(p, gameStats.saveType [ "Gamepass?" ] [ "GamepassId" ] ) then |
113 | passedPlayer(p, isLeaving) |
115 | elseif gameStats.saveType [ "Asset/Item?" ] [ "DoIt?" ] then |
116 | if p:PlayerOwnsAsset(p, gameStats.saveType [ "Asset/Item?" ] [ "AssetId" ] ) then |
117 | passedPlayer(p, isLeaving) |
127 | if p:findFirstChild( "leaderstats" ) then |
128 | lStats = p:findFirstChild( "leaderstats" ) |
139 | playerS [ "PlayerAdded" ] :connect(pAdded) |
140 | playerS [ "PlayerRemoving" ] :connect(pLeaving) |
If this won't work make sure that api is ON