RemoteEvent fire innocent data

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want remoteevent to fire correct data

  2. What is the issue? RemoteEvent fire wrong data

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes I have

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

MESSY ALERT (Script)

print(currentData) --Line 24
			
			currentData[num] = value

			print(currentData) -- Line 28

			Data:SetAsync(player.UserId, currentData)
			
			print(currentData) -- Line 32

			SetData:FireClient(player, currentData)

CodeManager (LocalScript)

SetData.OnClientEvent:Connect(function(data)
	print(data) --Line 770
	
	for num, value in pairs(data) do		
		data[tonumber(num) or num] = value
	end
	
	print(data) --Line 776
	
	CodeData = data
end)

Output:

{
                    [1] = true
                 }  -  Server - MESSY ALERT:24
  18:41:32.558   ▼  {
                    [1] = true,
                    [13] = true
                 }  -  Server - MESSY ALERT:28
  18:41:33.258   ▼  {
                    [1] = true,
                    [13] = true
                 }  -  Server - MESSY ALERT:32
  18:41:33.292   ▼  {
                    [1] = true
                 }  -  Client - CodeManager:770
  18:41:33.292   ▼  {
                    [1] = true
                 }  -  Client - CodeManager:776

SetData is a remote, Same for all

Thanks for reading, Feel free to ask me for something! :smiley:

Also here is the entire MESSY ALERT’s code

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Data = DataStoreService:GetDataStore("CodesData")

local Remotes = ReplicatedStorage.Remotes
local SetData = Remotes.SetData

local function UnToObtain(player, num, value)
	--pcall(function()
		local PlayerGui = player.PlayerGui
		local Gui = PlayerGui.Gui
		local Inputer = Gui.Inputer
		local Codedex = Gui.Codedex
		local Indexer = Codedex.Indexer
		local TopBar = Codedex.TopBar
		local InfoPage = Codedex.InfoPage
		local Collected = TopBar.Collected

		if not Data:GetAsync(player.UserId)[num] then
			local currentData = Data:GetAsync(player.UserId)
			
			print(currentData)
			
			currentData[num] = value

			print(currentData)

			Data:SetAsync(player.UserId, currentData)
			
			print(currentData)

			SetData:FireClient(player, currentData)
		else end
	--end)
end

Players.PlayerAdded:Connect(function(player)
	local Character = player.Character or player.CharacterAdded
	
	repeat
		task.wait()
	until player:FindFirstChild("PlayerGui"):FindFirstChild("Gui")
	
	local PlayerGui = player.PlayerGui
	local Gui = PlayerGui.Gui
	local Inputer = Gui.Inputer
	local Codedex = Gui.Codedex
	local Indexer = Codedex.Indexer
	local TopBar = Codedex.TopBar
	local InfoPage = Codedex.InfoPage
	local Collected = TopBar.Collected
	
	local data = Data:GetAsync(player.UserId)
	
	print(data)
	
	if not data then
		Data:SetAsync(player.UserId, {})
	end
	
	local dataToSend = {}
	
	for num, value in pairs(data) do		
		dataToSend[tonumber(num) or num] = value
	end
		
	SetData:FireClient(player, dataToSend)
end)

SetData.OnServerEvent:Connect(function(player, num, value)
	UnToObtain(player, num, value)
end)

Nvm I got it (300000000000000000 char)

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