I’m noob at scripting
I am trying to make a weapon upgrade system, damage value is in module script, is it possibly to make something like that in module script?
Damage = game.Workspace.Folder.Value
Сan it be like that?
Yes, you can set a module script value like that. You will need to make sure to update the damage variable though, since if you don’t it’ll stay at what it was set at.
Make your module something like this:
local module = {}
module.Damage = 25
return module
Then from another script, use the module’s variable or edit it:
local module = require(script.ModuleScript)
print(module.Damage)
module.Damage = 50
print(module.Damage)
Remember to use :WaitForChild()
on the client.
It works but when i change the value it stays the same, how to update it?
Here is the script:
wait(9)
game.Workspace.Folder.Value.Value = 100
Damage stays the same .
In the module script you mean?
If this is the module
local module = {}
module.Damage = 25
return module
You would have to do something like this in the main script:
local module = require(script.ModuleScript)
game.Workspace.Folder.Value:GetPropertyChangedSignal("Value"):Connect(function()
module.Damage = game.Workspace.Folder.Value.Value
end)
If you mean the value instance, then make sure you do it in a server script
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.