Output from ModuleScript

Well, here we go again: I’m trying to make a gun system with ammo being counted on a GUI, how would I be able to get output from a modulescript?
Thanks!

Is the module script the Gun Settings module script? Are you able to show me it?

Yes, I’ll attach a .PNG
image

1 Like

What I do is, have an Integer Value inside of my tool, with its value being the amount of bullets the gun can hold, getting the amount from the Settings module. In the GUI that you will have, you can require the module and add the amount of bullets it can hold, and the current amount of bullets there are in the mag.
Like: 30/30, Ammo inside of Mag/Ammo you weapon is capable to hold.

You can have a value.Changed function, and when a change happens, it will make changes to the GUI.

intValue.Changed:Connect(function(value)
   myGui.Ammo.Text = value
end)

Ah, okay, that’d be easier: But however, now I have to get the actual output of the ammo value in the ModuleScript to the Integer. So that’d also be a problem…

Sorry by the way, I’m kinda new to using values and modules.

You can just add the Integer from the Explorer, set the value to 30, and the changes will be done with the RemoteEvent that you will possibly be firing, will decrease the ammo, or increase it depending if you reload. Only thing that you will have to do with the ModuleScript is get the MaxAmmo that can be carried for each mag, so it can be added in the GUI, and with Server Checks to prevent the exploitation of your weapons.

No worries, it becomes easier the more you use them.
I suggest you to read this, as it’s a big help if you haven’t already, check youtube videos, or work with open-sourced codes so you can learn off of them.

ModuleScript | Roblox Creator Documentation.