Server says one thing, client says another

I am trying to make a quest system but when I check the keys and values tables on the server side, they are what they should be, however, on the client, they are both empty tables. Does anyone know why?

Client Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Quests = ReplicatedStorage.Quests
local Modules = ReplicatedStorage.Modules

local ToastModule = require(Modules.ToastNotifications)

local Template = script.Template

local QuestFrame = script.Parent
local MainFrame = QuestFrame.Frame
local Close = QuestFrame.Close

function OnClose()
	script.Parent.Parent.Enabled = false
end

function FinishQuest(QuestName, TextA, TextB, Icon)
	ToastModule.CreateToast("QuestFinish", TextA, TextB, Icon, 5)
	MainFrame:FindFirstChild(QuestName):Destroy()
end

Close.MouseButton1Click:Connect(OnClose)

Quests.FinishQuest.OnClientEvent:Connect(FinishQuest)

while task.wait(10) do
	local Keys, Values = Quests.RequestUpdate:FireServer()
	
	if Keys then
		for i, Quest in ipairs(Keys) do
			if MainFrame:FindFirstChild(Quest) then
			else
				local QuestGui = Template:Clone()
				QuestGui.Name = Quest
				QuestGui.Parent = MainFrame
			end

			local Number = 0
			local Current = nil

			repeat
				Number = Number + 1
				Current = Keys[Number]
			until Current == Quest
			
			if MainFrame:FindFirstChild(Quest).Text ~= Values[Number] then
				MainFrame:FindFirstChild(Quest).Text = Values[Number]
			end
		end
	end
end

Server Script

local Quests = game.ReplicatedStorage.Quests

function OnPlayerAdded(Player)
	Instance.new("Folder", Player).Name = "Quests"
	
	local str = Instance.new("StringValue")
	str.Name = "TestQuest"
	str.Value = "LOLOLLOLLOLOLOLOLOL"
	str.Parent = Player:FindFirstChild("Quests")
end

function OnRequestUpdate(Player)
	local Keys = {}
	local Values = {}
	
	for i, Quest in ipairs(Player:WaitForChild("Quests"):GetChildren()) do
		print(Quest)
		table.insert(Keys, Quest.Name)
		table.insert(Values, Quest.Value)
	end
	return Keys, Values
end

game.Players.PlayerAdded:Connect(OnPlayerAdded)
Quests.RequestUpdate.OnServerEvent:Connect(OnRequestUpdate)
1 Like

FireServer and FireClient don’t return anything. You can use RemoteFunctions for this, but only for client-server-client calls. Don’t do server-client-server calls, as a hacker would be able to prevent the RemoteFunction from ever returning, causing the server to wait forever.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.