Hey Guys! Trying to redo a previously working dress-up menu.
While it was functional, it was extremely ineffective as it used two different scripts and a remote event for each item. Currently, I’m trying to make use of a module script to manage the entire menu. (i.e. each item of a similar type should use the same functions). So each image button of the same type of accessory will have the same script + an object value that holds a different accessory (again of the same type). I understand the general concept of module scripts however I think I’m having a hard time implementing them.
Any help/feedback is really appreciated!
I’ve done some scripting based on how the old system worked (for full dresses alone so far) but it isn’t working or returning any errors.
Here is the Module Script
local DressUpModule = {}
function DressUpModule.doHair(player)
--reserved for later
--add hair accessory + texture if necessary
end
function DressUpModule.fullDress(player)
print("Button Pressed")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fullDressEvent = ReplicatedStorage.FullDressEvent
local dress = script.Parent.Dress
script.Parent.Parent.Parent.Enabled = false
print(player.Name)
fullDressEvent:FireServer(player,dress)
end
function DressUpModule.fullDressServer(player,dress)
local name = player.Name
print(name, "has activated the event")
local accessory = dress
accessory.Parent = player.Character
local humanoid = player.Character.Humanoid
humanoid.HipHeight = 4.2
end
return DressUpModule
Client Script (this is the local script for when a player presses any of the GUI buttons)
ServerStorage = game.ServerScriptService
local DressUpModule = require(ServerStorage.DressUpModule)
DressUpModule.fullDress(game.Players.LocalPlayer)
Server Script: (For actually putting the dress on)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FullDressEvent = ReplicatedStorage:WaitForChild("FullDressEvent")
local function eventFire()
local ServerStorage = game.ServerScriptService
local DressUpModule = require(ServerStorage.DressUpModule)
DressUpModule.fullDressServer()
end
FullDressEvent.OnServerEvent:Connect()