Passing data between scripts causes string value to return as data number

  1. What do you want to achieve? Keep it simple and clear!

I made a basic quest script. Trying to create an effective way to communicate between 2 module scripts and a server script (unless there’s a better solution). Here is the flow logic

Player has a choice selection > sets off remote event in a module handled locally based off the selection > event data comes from another module in rep. storage > values passed to a server script

  1. What is the issue? Include screenshots / videos if possible!

Everything is working so far, except that the string values in the module table are returning as a float/number (Instead of returning the string “The Quest’s Name” as an output I get something like “0.13848477585966”)

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

I’ve tried searching roblox forums for similar problems, but none quite like mine. I’ve seen problems/solutions (an have encountered this issue) in other coding languages, but don’t know how to translate it to Lua.

I hoped for an easy data tostring() conversion method, or thought maybe a jsonDecode thing was needed. Also considered using roblox’s recent attributes feature instead but feel it would pose the same problem

The data is being passed, it’s just represented as a number

Here are my scripts, which I’ve simplified:

Module in Replicated Storage:
local module = {}
module.QuestTest = {
   Name = “A test name”,
   Item = “An Item”,
   Max = 5,
   — //.....
}
return module
Server Script
— loops through module to find data values
function getModule(player, module, input)
   for key, value in pairs (module) do
       if key == input then   — line breaks 
              local name = value.Name
              print(name)  
              — // ....
        end
   end 
end

event:OnServerEvent(getModule)
Client Module
local qModule = require(repStore.module)

event: FireServer(player, qModule, “QuestTest”)

OUTPUT:

attempt to index number with value 

New Attempt
Here is another way of understanding the issue

Client Module

(I put the server loop code from above in here)

local qModule = require(repStore.module)

for key, value in pairs (qModule) do
    if key == “QuestTest” then
           local questName = value.Name
           local questItem = value.Item
           local questMax = value.Max

           print(questName) — printing name now works
           print(questItem)

           event:FireServer(player, questName, questItem, questMax)
     end
end 
Server Script

(Since the original function is now in the client script, this is next step I would call with remote events)

— creates new player instances
function newVal(player, questName)
   local newVal = Instance.new(“IntValue”)
   newVal.Name = “newVal”..questName
   print(questName) — printing passed value name now doesn’t work 
   print(newVal.Name)
end

function maxVal(player, questItemName, questMaxVal)
   local maxItem = Instance.new(“IntValue”)
   maxItem.Name = “Max”..questItemName — break
   — //...
end

function createQuest(player, questName, questItemName, questMaxVal)
   newVal(player, questName)
   maxVal(player, questItemName, questMaxVal)
end

event:OnServerEvent(createQuest)

OUTPUT (from print statements)

A Test Name
QuestItem
0.98664860867784
newVal0.98664860867784
attempt to concatenate string with Instance 

Thanks to everyone in advance. Again, the script itself basically works it’s just that the values are being translated numerically. If someone can explain why, and a workaround it’d help so much!

Try putting “.Name” after questName

I realized I wrapped the remote event in a secure event module which generates a unique user
key. the secure event was created by another dev, and works in other scripts but this one is causing issues. when I remove it and call the event normally I got it to work after tweaking some code. issue still remains, I’ll have to look into it myself or create a new topic