I have 2 scripts (One a Server script, the other a ModuleScript) the server script fires a function in the module scripts and sends in some variables. Here are the scripts:
Server Script;
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local DS2 = require(script.Parent.Parent.DS2Module)
local SDMModule = require(script.Parent.Parent.SDMModule)
ReplicatedStorage.Remotes.Events.SDM.OnServerEvent:Connect(function(Player)
local PlayerIdFolder = ServerStorage:FindFirstChild(Player.UserId.." Folder")
if PlayerIdFolder then
if Player.Character then
local Character = Player.Character
local Tool = Character:FindFirstChildOfClass("Tool")
if Tool then
if Tool:FindFirstChild("Active") and Tool.Active:IsA("BoolValue") then
local Active = Tool.Active
if Active.Value == false then
Active = true
SDMModule(Tool, Player, DS2, Active)
end
end
end
end
end
end)
ModuleScript;
local function CheckSDM(SelectedTool, Player, DS2, Active)
local function StrengthTool(StatName)
local BasePlayerData = DS2(StatName.."Dat" or "StrengthDat", Player):Get()
local MultiPlayerData = DS2(StatName.."MultDat" or "StrengthMultDat", Player):Get()
if Active.Value == true then
BasePlayerData:Increment(MultiPlayerData)
wait(2)
Active.Value = false
return Active
end
end
local function ResistanceTool(StatName)
local BasePlayerData = DS2(StatName.."Dat" or "DefenseDat", Player):Get()
local MultiPlayerData = DS2(StatName.."MultDat" or "DefenseMultDat", Player):Get()
if Active.Value == true then
BasePlayerData:Increment(MultiPlayerData)
wait(2)
Active.Value = false
return Active
end
end
local function MeditationTool(StatName)
local BasePlayerData = DS2(StatName.."Dat" or "MagicDat", Player):Get()
local MultiPlayerData = DS2(StatName.."MultDat" or "MagicMultDat", Player):Get()
if Active.Value == true then
BasePlayerData:Increment(MultiPlayerData)
wait(2)
Active.Value = false
return Active
end
end
if string.find(SelectedTool.Name, "Meditate") then
MeditationTool("Magic")
end
if string.find(SelectedTool.Name, "Strength") then
StrengthTool("Strength")
end
if string.find(SelectedTool.Name, "Resistance") then
ResistanceTool("Defense")
end
end
return CheckSDM
The problem is in the modulescript when I use Active.Value (Active is a BoolValue) it errors and says attempt to index boolean with ‘Value’.
BasePlayerData:Increment(MultiPlayerData)
wait(2)
Active.Value = false
return Active