Hi! I’m trying to make a customization system. There are multiple ModuleScripts for each function. Buy, Equip, Remove and more. But the script doesn’t see the ModuleScripts in that moment somehow.
local Modules = {}
for i,v in pairs(ModulesFolder:GetChildren()) do --get modules --[[script.Module]]
Modules[v.Name] = require(v) --add them to modules (table)
end
game.ReplicatedStorage.AvatarCustomizationEvent.OnServerEvent:Connect(function(plr,Module,...)
Modules[Module](plr,...,Settings)
end)
Is your module table set up as intentional, have you checked it with a print statement?
I don’t understand the line Modules[v.Name] = require(v), if you are adding them to a table
wouldn’t you want Modules[#Modules+1] = require(v)?
The firing script is stored in a button in the shop frame
This is where the RemoteEvent gets fired
game.ReplicatedStorage[Settings.RemoteEventName]:FireServer("BuyArm",script.Parent.ProductName.Text)
if player.OwnedArms:FindFirstChild(ProductName) then --if player owns it
if FindFirstChildProductName.Value == false then --if not equipped, equip
game.ReplicatedStorage[Settings.RemoteEventName]:FireServer("RArm",script.Parent.ProductName.Text)
wait()
game.ReplicatedStorage[Settings.RemoteEventName]:FireServer("EArm",script.Parent.ProductName.Text)
I hired a scripter to do this so I don’t know what the line says either. I’m sorry for being not able to tell what the code says
I’m sorry for asking again and I’m sure you’re currently doing something else but I have an error again. So I changed the “ArmScript” code (the script in the frame which a button is in which you can click on and buy the arm) to the updated modulescript names
script.Parent.TextButton.MouseButton1Click:Connect(function()
game.ReplicatedStorage[Settings.RemoteEventName]:FireServer("BuyArm",script.Parent.ProductName.Text)
if player.OwnedArms:FindFirstChild(ProductName) then --if player owns it
if FindFirstChildProductName.Value == false then --if not equipped, equip
game.ReplicatedStorage[Settings.RemoteEventName]:FireServer("RemoveArm",script.Parent.ProductName.Text)
wait() --debug
game.ReplicatedStorage[Settings.RemoteEventName]:FireServer("EquipArm",script.Parent.ProductName.Text)
player.IsStarterArm.Value = true
player:WaitForChild("C_EquippedArms"):FindFirstChild(script.Parent.ProductName.Text).Value = true
elseif player:WaitForChild("C_EquippedArms"):FindFirstChild(script.Parent.ProductName.Text).Value == true then --if the arm is equipped, unequip
but now there’s an error in “BodyCustomization” again. It says
local ModulesFolder = script.CustomizationModules --line 69
local Modules = {}
for i,v in pairs(ModulesFolder:GetChildren()) do --get modules --[[script.Module]]
Modules[v.Name] = require(v) --add them to modules (table)
--Modules[#Modules+1] = require(v)
end
game.ReplicatedStorage.AvatarCustomizationEvent.OnServerEvent:Connect(function(plr,Module,...)
Modules[Module](plr,...,Settings)
print(Module)
print(table.concat(Modules,','))
end) --line 81
Ok, can you try adding a print line here to see if there is actually something getting added?
for i,v in pairs(ModulesFolder:GetChildren()) do --get modules --[[script.Module]]
Modules[v.Name] = require(v) --add them to modules (table)
--Modules[#Modules+1] = require(v)
print('added module named',v.Name)
end
14:53:57.444 added module named EquipArm - Server - BodyCustomization:81
14:53:57.445 added module named RemoveArm - Server - BodyCustomization:81
14:53:57.445 added module named EquipEffect - Server - BodyCustomization:81
14:53:57.445 added module named RemoveEffect - Server - BodyCustomization:81
14:53:57.445 added module named BuyEffect - Server - BodyCustomization:81
14:53:57.445 added module named BuyArm - Server - BodyCustomization:81
local ModulesFolder = script.CustomizationModules
local Modules = { }
for i,v in pairs(ModulesFolder:GetChildren()) do --get modules --[[script.Module]]
Modules[v.Name] = require(v) --add them to modules (table)
--Modules[#Modules+1] = require(v)
print('added module named',v.Name)
end
print(Modules) -- ok can u tell me what it says here
game.ReplicatedStorage.AvatarCustomizationEvent.OnServerEvent:Connect(function(plr,Module,...)
print(Module)
print(Modules) -- also here
Modules[Module](plr,...,Settings)
end)