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
Players.PlayerAdded:Connect(function(Player)
local PlayerID = Player.UserId
local StatData = {Strength = 1, Speed = 2}
Module.AddPlayer(PlayerID,StatData)
end)
Players.PlayerRemoving:Connect(function(Player)
local PlayerID = Player.UserId
Module.RemovePlayer(PlayerID)
end)
-- This Remote will print out the user's current Data.
Remote.OnServerEvent:Connect(function(Player)
local PlayerID = Player.UserId
local StatData = Module.ReturnData(PlayerID)
print(StatData)
end)
-- This Remote will raise the user's current strength by one.
Remote2.OnServerEvent:Connect(function(Player)
local PlayerID = Player.UserId
local StatData = Module.ReturnData(PlayerID)
end)