Hey! I’m looking for a way to get variables from other functions – without using ‘return’, because in my circumstance this wouldn’t work. The issue comes when I’m trying to add stats to a player with it’s function being it’s own. I’ve tried using some things I doubted myself would work, and I’ve searched the devfourm – and didn’t find anything to answer my problem.
The module is required by one core script.
local PlayerManager = require(ServerModules.PlayerManager)
Players.PlayerAdded:Connect(function(Player)
PlayerManager:RunServer(Player)
end)
Here’s the code:
local M = {}
function M:IncreaseValue()
-- I want to gather the value from the RunServer function.
end
function M:RunServer(Player)
local StatsFolder = script.PlayerInfo
local PlayerInfo = StatsFolder:Clone()
local PlayerStats = PlayerInfo.Stats
local Hunger, Energy, Health = PlayerStats.Hunger, PlayerStats.Energy, PlayerStats.Health
PlayerInfo.Parent = Player
local Role, Rank = PlayerInfo.Role, PlayerInfo.Rank
Role.Value = tostring(Player:GetRoleInGroup(GROUPID))
Rank.Value = Player:GetRankInGroup(GROUPID)
end
return M