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

Why doesn't this RemoteEvent work?

Asked by
wentman 19
6 years ago
Edited 6 years ago

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

0
Please indent your code correctly, it makes understanding it a LOT easier for both you and other people. LisaF854 93 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Well, I have a simple answer. When using RemoteEvents they can not return any values. But if you use a RemoteFunction you can freely return any value.

I can't provide you a modified version of your code due to the poor indentation.

0
Nevermind what I said. Thanks wentman 19 — 6y
0
Nice answer! LisaF854 93 — 6y
Ad

Answer this question