Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

A question about module scripts?

Hello,

I've just started to research about module scripts and how they work etc. and now I'm giving it a go myself.

local module = {}

module.ShopText = function(Text, Color, Delay, Value)
	
	
end

return module

The problem is that I want to access the PlayerGui inside this function. However, I am unsure in how to write this since I don't think I can say game.Players.LocalPlayer.

Any help on this issue is appreciated.

1 comment

0

Since it's a script for PlayerGui, you'd use a localscript which now would allow you to use player as a variable.

1 answer

✓ Accepted answer

when you require a modulescript, it "inherits" the traits of a localscript or a server script depending on which type of script required it

that means, if you require it using a localscript, you can use things that only the client has access to, like LocalPlayer and UserInputService

likewise, if you require it using a serverscript, then you can use things like HttpService and DataStoreService, which only work on the server

so, as long as you're only requiring that module on the client, you'll be able to use LocalPlayer just fine

This discussion is preserved as it was. New answers, comments, and votes are closed.