How do i change it?

So I am trying to change damage of the weapon, but it doesn’t work, can someone explain!image

1 Like

Is “Damage” a paremeter?
30 limit

Do you mean this?
image
sorry, I am quite new to module scripts

Well that’s not a module script that’s a table if it’s a module script it would be this:

local module = {}

module.Damage = 3.5

return module

This is a module script

I meant something like this:

function module.Burger(Damage)

Lol what? What OP did and what is shown here has nearly no difference between them

Except a module script you don’t put the items into the table, you use module.item and then return module

How can i change the table contents then?

Just make all things in your table follow the module and then you’ll be able to do stuff like:

module.Damage = 7

Because it’s a module now

Doing that is the same as:

local module = {
    Damage = 3.5
}

In the code you gave, your referencing a empty table then adding “Damage”.
And in this code I’m referencing a dictionary with “Damage”.

If you say so I have never seen a module like that and was taught the other way so

What if you try module[“Damage”]

  1. Is there an error in the output, or does it just not do anything when you change the value?

  2. How is the Settings module being implemented in NewAttack? Is this a free model?

No I did it my self it’s not giving an error too

1 Like

Assuming NewAttack is what implements the Settings module, can you show the code used in NewAttack?

While you’re at it, can you show the code in the Settings module too?

You would essentially want to reference the Damage setting from the module instead of putting it in a local variable or function argument. That’s if you want to monitor the setting live anyway.

New attack doesn’t use damage due to problems it’s another script, I placed it there, so I won’t get confused
it uses a part that damages
image

1 Like

So it’s not a live variable problem…

Are you sure the code in the user input portion in the OP is running? Maybe it’s missing one of the conditions. Try adding a print right before the module change and see if it shows up.

UIS.InputBegan:Connect(function(key, isTyping)
    if isTyping == false then
        if equipped == true then
            if key.KeyCode == Enum.KeyCode.Q then
                print("CHANGING DAMAGE")
                local module = require(script.Parent.NewAttack.Settings)
                module.Damage = 7
                -- ...

Is the separate script referencing the right settings module?

Is the changing script and the damaging script on the same side of the client-server boundary? Client scripts can’t change module settings on the server, you would have to send an update through a remote to do that.

Yes it is and there’s code after changing damage, so normally it wouldn’t work right?
Remote event? How would I make it work

You can set up a remote event in replicated storage such that when the server receives the firing client, it goes to that settings module and changes the setting itself.

e.g. you could have a remote named PressQ. The client fires it when they press Q:

local ReplStorage = game:GetService("ReplicatedStorage")

local PressQ = ReplStorage.PressQ

UIS.InputBegan:Connect(function(key, isTyping)
    if isTyping == false then
        if equipped == true then
            if key.KeyCode == Enum.KeyCode.Q then
                print("CHANGING DAMAGE")
                PressQ:FireServer()
                -- ...

And on the server, it would listen to the event and make the proper changes to the Damage setting.

local ReplStorage = game:GetService("ReplicatedStorage")

local PressQ = ReplStorage.PressQ

PressQ.OnServerEvent:Connect(function(player)
    local module = require(path.to.NewAttack.Settings)
    module.Damage = 7
    -- ...
end)

How do i access newattack if it’s in tool tho