Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] This whitelist system that uses Datastore is not working and doesn't output any error?

Asked by 4 years ago
Edited 4 years ago

(Edit: fixed OnServerEvent and updated the GUI Code)

So I am making a Datastore whitelisting system, basically I can whitelist, unwhitelist, or view who is whitelisted via a GUI.

How my system works is to use RemoteFunctions (to return stuff, also don't get confused if the RemoteFunction name is UTGJRemoteEvent)

The problem is that my code doesn't work and doesn't output any error. And yes I enabled studio API access. (Because I was testing it on studio). When I clicked whitelist, unwhitelist, or get users whitelisted on my GUI, all of them say that is failed (I made a status system that can say wether it succeded or failed.), and my output says that it failed as well (I added a warn everytime Datastore fails)

Server script: (the datastore and code is classified.)

001local DataStore = game:GetService("DataStoreService")
002local UTGJDS = DataStore:GetDataStore("classified")
003 
004local remote = game.ReplicatedStorage:WaitForChild("UTGJRemoteEvent")
005local code = "classified"
006 
007game.Players.PlayerAdded:Connect(function(plr)
008    plr.Chatted:Connect(function(msg, recipient)
009        if string.lower(msg) == string.lower("giveutgj") and not recipient then
010            local getallowed, atable = pcall(function()
011                return UTGJDS:GetAsync("Username")
012            end)
013 
014            if getallowed then
015                for i, v in pairs(atable) do
View all 176 lines...

(I am sorry if it's hard to read)

GUI Code:

01local remote = game.ReplicatedStorage:WaitForChild("UTGJRemoteEvent")
02local code = ""
03 
04local openclose = script.Parent:WaitForChild("Open")
05local frame = script.Parent:WaitForChild("Frame")
06local usertextbox = frame:WaitForChild("Username")
07local whitelist = frame:WaitForChild("Whitelist")
08local unwhitelist = frame:WaitForChild("Unwhitelist")
09local status = frame:WaitForChild("status")
10local getuserframe = script.Parent:WaitForChild("GetUsersUTGJ")
11local textgetuser = getuserframe:WaitForChild("Users")
12local getuserbutton = getuserframe:WaitForChild("GetUsers")
13 
14openclose.MouseButton1Click:Connect(function()
15    if frame.Visible == true then
View all 70 lines...

(Also the string replaced with "no" is me and my friend)

Can anyone help please?

Thanks, Ethan

0
After I rewrote the PlayerAdded chat event, it works. So I'll try rewriting the whitelist, unwhitelist, and get user. Still if you can awnser the problem, please do that in case after I rewrite it fails again. RadiatedExodus 41 — 4y
0
Using SetAsync works but UpdateAsync doesn't work, which is strange. RadiatedExodus 41 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

SetAsync fixes the problem.

Ad

Answer this question