How to Update Information in an existing Module Script?

I want to be able to update information within a Module Script from a Script, but I don’t quite know how to go about that. Does anyone have any resources that could help me do this? . . Or any ideas that I could try?

There used to be this one post about Saving Player Data on the Roblox Developer Wiki, but I think it was too complex and got replaced because I can’t find it again

This is what my server script looks like by the way.

-- Variables --

local Module = require(game.ServerScriptService.DataModule)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = game.ReplicatedStorage.Practice
local Remote2 = game.ReplicatedStorage.Practice2

-- Functions --

-- Script

	local PlayerID = Player.UserId

	local StatData = {Strength = 1, Speed = 2}

	local PlayerID = Player.UserId

-- This Remote will print out the user's current Data.
	local PlayerID = Player.UserId
local StatData = Module.ReturnData(PlayerID)

-- This Remote will raise the user's current strength by one.
	local PlayerID = Player.UserId
	local StatData = Module.ReturnData(PlayerID)


You can just set it like a variable I thought:

Module.WhateverDataYouWantToChange = NewChange
1 Like

Thank you, I didn’t know that if you just updated it in the server it automatically changed the ModuleScript.

I’m confused as to how that works, but it does, I thought you’d have to put return somewhere or something.

I’m really bad at using returning