Hello! I’m a scripter making a roblox lost like game. And I’m working on my placement system, I haven’t scripted in a bit so what’s a good way to call the player and also make the script look clean instead of doing
game.Players.PlayerAdded:Connect(function(player)
end)
Well, depends. There are multiple ways to get the player.
- Touching a part
- Via the username (maybe some player typed it)
- Events (PlayerAdded)
- RemoteEvents / RemoteFunctions
PlayerAdded is super useful, and if the condition is right you should use it. There’s no “bad” way to get the player, it depends on the situation. See what you have in terms of scripts and stuff, and then think of the best way you can send data to the server. Maybe when they click a button? You know, the button to start placing (idk). It depends on what you’ve written - don’t worry about making clean code that’s not as efficient. Efficient code > Clean code. But, Efficient Clean Code > Clean Code. So, don’ take efficiency out for clean code.
Hmm, I’ll start using it more often Thanks!
Well, PlayerAdded only fires once. So you can’t “use it more often” just sort of save the function for later. For example.
game.Players.PlayerAdded:Connect(function(plr)
plr["some value"].Changed:Connect(function()
-- do stuff
end)
end)
1 Like