#PlayerSetup Script Help

1 messages · Page 1 of 1 (latest)

raw shore
#

Hi, I am making a tycoon and I already created functions to assign a tycoon to a player, but this is my first game and I'm not sure what to do here:

local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")

local TycoonController = require(ServerScriptService:WaitForChild("TycoonController"))
local DroppingController = require(ServerScriptService:WaitForChild("DroppingController"))



local function setCollision(character)
    local characterParts = character:GetChildren()
    for _, part in ipairs(characterParts) do
        if part:IsA("BasePart") then
        part.CollisionGroup = "Players"
        end
    end
end

local function assignTycoon(player)
    local tycoon = TycoonController.claimTycoon(player)
    local drop = DroppingController.dropPart(tycoon)
    player.CharacterAdded:Connect(setCollision)
end

Players.PlayerAdded:Connect(assignTycoon)

So I have my PlayerAdded connected to assignTycoon, but I realized that I also need to add my leaderstats script on player join, so do I create a brand new PlayerAdded connection, or do I instead just create a new onPlayerJoin function and call assignTycoon and pass the player to it right after the function is called if that makes sense? Sorry if it's hard to understand, I'm quite new.

#

@clever timber

clever timber
#

uhh

#

i think your best option is to juist do playeradded:connect(function() --logic end)

raw shore
#

For assign tycoon, or for the leaderstats?

clever timber
#

or if you really want it to all stay in a function, create another function combining the leaderstats thingy and assigntycoon and do what you did with assigntycoon bhut with the new function

clever timber
#

function

#

something like:

raw shore
#

I see I'm just unsure if it would get confusing to read for example if I eventually add people to my project you know? like onPlayerJoin makes sense because it's unambiguous, and so is assignTycoon

#

but if i were to combine them it may get confusing

clever timber
#
players.playeradded:connect(function(player)
  assigntycoon(player)
  leaderstatsfunction(player)
end)
clever timber
#

then again if im correct your a beginner no?

raw shore
#

Yeah I am like

#

3 weeks in I think

clever timber
#

dont focus on readability

raw shore
#

Really?

clever timber
#

your not good enough to start working with other people on full games (no offense)

raw shore
#

nah you're right but im talking about in the future

clever timber
#

id rather you focus on knowing the basics of luau, with that your able to create anything you want

clever timber
raw shore
#

you're probably right I feel like

#

idk if this happens for you but

#

I'm being like a perfectionist

#

ykwim

clever timber
#

theres no specific tutorial that explains how to make your code the most readable, but you will learn it along the way

clever timber
#

but ive learned to just ignore it

raw shore
#

Yeah im just worried about bugs like

clever timber
#

just make sure you get progress in

raw shore
#

yeah you have a good point

#

im probably hindering myself

clever timber
#

if you end up not liking the code, you could always remake it (not the most fun thing ik)

raw shore
#

also what do you think about AI giving me hints as a beginner is that a no no?

clever timber
#

if you focus on your code being "good" right now too much then you will get nowhere, trust me ive had the same experience

clever timber
#

i mean ive done it before but it made me heavily reliable on ai

raw shore
#

Like no code writing at all but

#

yeah

clever timber
#

id rather not do it

raw shore
#

But Ive noticed since I stopped im learning more

clever timber
#

I do agree it helps alot, but unless you have no knowledge in the project your making i wouldnt use it if i were you. Try to rely on your common sense more

raw shore
#

Yeah I think it's because

#

im such a little novice that

#

Im worried ill break things

#

or that it'll be easily exploitable

clever timber
#

dont worry about that

#

your currently making projects to get better, no?

raw shore
#

yes thats true, but I also would like to eventually make it a job

#

you're right tho if its ass its ass

clever timber
#

you should focus on making sure it works

#

not the security

raw shore
#

nah you're right

clever timber
#

you will always imrpove

raw shore
#

are youtube tutorials fine?

clever timber
#

and you will realize the mistakes you made early on

clever timber
#

there are some niche tutorials for specific projects but they usually write ass code

raw shore
clever timber
#

unless your watching tutorials that explain scripting as a whole, i stand with my point

raw shore
#

As a beginner I dont want to rely on AI, or copy code, but sometimes like

#

for instance adding a playlist to my game

#

I have no idea how to do that

#

and some things I have no idea even existed

#

like materialvariants

clever timber
#

you learn it along the way

#

i still have some projects where i have no experience with

#

thus i am unable to code it

#

but soon time will arrive and i end up making the project

#

by the time i finished i will know how it works

raw shore
#

Ur right then I'll just slowly improve

clever timber
#

and the better you get at coding, the next time you create it you will see the small mistakes you amde

#

and you will improve

raw shore
#

I appreciate ur advice bro

clever timber
#

right now the thing thats hindering you is probably impatience

raw shore
#

ill do my bes tto stick to

#

robloxdocs

#

and experiemnt

clever timber
#

ive had the same experience, still to this day

raw shore
#

experiment

clever timber
#

to get better, to make money etc

raw shore
#

I want to release a game so bad but it's really tough when you're new

#

no animators, vfx, modelers etc

#

Im gonna need to learn it all

clever timber
#

just be patient

#

you will soon figure it out

raw shore
#

bet

#

Thank you

clever timber
#

and by then you will be happier to have found that skill rather than releasing a game your unhappy with