#Help with modules
1 messages · Page 1 of 1 (latest)
also the server script
local plr
game.Players.PlayerAdded:Connect(function(player)
plr = player
end)
local modulescript = require(game.ReplicatedStorage.ModuleScript)
modulescript.easy()```
pass plr var into function
simplify please im unemployed 💔
that is simplified
im dumb asf i just realized var here means variable and not video assistant referee
That was simplified as it gets 😔
demote him
i passed the variable, still nothing
it should be
it still prints out "nil", i even used an if statement to see if there is a player
where did you pass the var
The way you have it doesn't allow for passed variables
how fix
wait actually
that isnt the problem
it allows for them
it's just the piece of code you're running to fire the function is running before the player joins lol
dude you want to run the code in play mode not in test mode
ill put wait thing then
or jsut put that function into playeradded
instead of plr var pass the player variable straight in
okay i got it
Just put it into the player added lol
i just woke up im getting dumb
^ and im clearly getting tired
dw vru, i wake up and im still dumb by afternoon
k thanks guys
👍
you know you can just do like
local module = {}
function module.easy(player)
print("Ez gg")
print(player)
end
return module
but theres many ways to use a module
🤷♂️
thats how you use modules ^^^
but at first I also had problems to understand modulescripts
cuz I didnt know for what reason I could need them
after I discovered "OOP" I slowly understood the usage of modulescripts
once you get to a level of understand oop and module scripts your life just gets easier
I would highly recommend going into roblox forums to understand
https://devforum.roblox.com/t/roblox-oop-object-oriented-programming/1639499/8
this is where I learned OOP (Object Orientated Programming). After seeing this I started using Modules and I basically improved so much than before
** You are now Level 16! **