Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't this RemoteEvent work?

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

0

Please indent your code correctly, it makes understanding it a LOT easier for both you and other people.

1 answer

✓ Accepted answer

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.

2 comments

0

Nevermind what I said. Thanks

0

Nice answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.