I am creating a player look-up system using a GUI, and I need Client to Server communication in order to use the DataStore system. But the server doesn't respond.
ServerScript
local DataStoreService = game:GetService("DataStoreService")
local Check = DataStoreService:GetDataStore("PayCheck")
game.ReplicatedStorage.GetServer.OnServerEvent:Connect(function(plr, TBox)
print("Yes")
local Players = game:GetService("Players")
local cache = {}
function getUserIdFromUsername(name)
local player = Players:FindFirstChild(name)
if player then
cache[name] = player.UserId
return player.UserId
end
local id
pcall(function ()
id = Players:GetUserIdFromNameAsync(name)
end)
cache[name] = id
return id
end
local key = "ID-"..(getUserIdFromUsername(TBox))
if DataStoreService:GetAsync(key)==nil then
return nil
else
local Data = DataStoreService:GetAsync(key)
return(Data[1])
end
end)
LocalScript
local TBox = script.Parent.EnterUser
TBox.FocusLost:Connect(function(enterPressed, inputThatCausedFocusLost)
print("Part1Complete")
game.ReplicatedStorage.GetServer:FireServer(TBox.Text)
end)
There is no errors in the Output, and the way I checked if the Server responds is with the Print() function

2 comments
https://gyazo.com/75aa18f9230a54cf6bbbff672c82e096
Please indent your code correctly, it makes understanding it a LOT easier for both you and other people.