I'm making a MMORPG shooter game. I have weapons that have a Configuration folder inside them, which have values. A ModuleScript will recognize these values and make them have use (such as damage, reload time, spread, etc.), but once they change, the ModuleScript won't use the new value and will use the original value. How can I make it recognize the new value?
CODE SNIPPETS (Separated)
local reloadtime = script.Parent.WeaponStats.ReloadTime
ReloadTime = reloadtime.Value
ReloadAnimationSpeed = reloadtime.Value + 0.2
(end) If you know what FE Gun Kit (by SuperEvilAzmil) is and you are fluent with values, i'm pretty sure you can help. You don't need to know what the gun kit is. (requested help on the unoffical roblox discord, but that didn't help me well.)
Variables connected to properties don't change when their corresponding property changes. Use this to help.
-- local reloadtime = script.Parent.WeaponStats.ReloadTime -- ReloadTime = reloadtime.Value -- ReloadAnimationSpeed = reloadtime.Value + 0.2 reloadtime.Changed:Connect(function() ReloadTime = reloadtime.Value ReloadAnimationSpeed = reloadtime.Value + 0.2 end)
EDIT: Still won't change? Weird, try this
-- local reloadtime = script.Parent.WeaponStats.ReloadTime -- ReloadTime = reloadtime.Value -- ReloadAnimationSpeed = reloadtime.Value + 0.2 local UpdateCoroutine = coroutine.create(function() while true do ReloadTime = reloadtime.Value ReloadAnimationSpeed = reloadtime.Value + 0.2 wait() end end) coroutine.resume(UpdateCoroutine)
EDIT EDIT: Still doesn't work??? nani?
here goes
-- at the start of the script local reloadtime = script.Parent.WeaponStats.ReloadTime local UpdateCoroutine = coroutine.create(function() while true do ReloadTime = script.Parent.WeaponStats.ReloadTime.Value ReloadAnimationSpeed = script.Parent.WeaponStats.ReloadTime.Value + 0.2 wait() end end coroutine.resume(UpdateCoroutine)
if this still doesn't work, it's not at the start of the script
if it still doesn't work at the start of the script, you misspelled something
if you copied it directly from the view source thingy that always is included with the lua thingy and it still doesn't work, then
while true do spawn(function() while true do spawn(function() spawn(function() while true do print("NANI?") end while true do print("NANI?") end while true do spawn(function() while true do print("NANI?") end end while true do print("NANI?") end end end end while true do spawn(function() spawn(function() while true do print("NANI?") end while true do print("NANI?") end while true do spawn(function() while true do print("NANI?") end end while true do print("NANI?") end end end end
IT DIDN'T WORK?????
while true do local corout = coroutine.create(function() while true do local corou = coroutine.create(function() while true do local coro = coroutine.create(function() while true do local cor = coroutine.create(function() while true do local co = coroutine.create(function() print("NANI?") end) coroutine.resume(co) print("NANI?") end end) coroutine.resume(cor) print("NANI?") end end) coroutine.resume(coro) print("NANI?") end end) coroutine.resume(corou) print("NANI?") end end) coroutine.resume(corout) print("NANI?") end