Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i take information from a module script to a server script?

Asked by
DevingDev 346 Moderation Voter
6 years ago

So i want for example change the value from the module sscript on the chicken to false but i want to change the value in the server script.

Heres my scripts. Module

local Animals = {
    ["Chicken"]= {
       ["Tameable"]= true,
       ["Health"]= 25,  
        }   
    }

return Animals

Server Script

local h = require(game.ReplicatedStorage.Animals.ObjectStats)
print(h.Animals["Chicken"][2],false)

Error:

1:32:39.479 - ServerScriptService.Script:2: attempt to index field 'Animals' (a nil value)
17:32:39.480 - Stack Begin
17:32:39.480 - Script 'ServerScriptService.Script', Line 2
17:32:39.481 - Stack End

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

You are indexing a value that does not exist, h is equal to the Animals table in the module script since you used return. So the correct way to index chicken would be,

local h = require(game.ReplicatedStorage.Animals.ObjectStats)

print(h.Chicken.Tameable)
Ad

Answer this question