#how do i convince roblox studio that PlayerScripts is infact a child/member of the player?

151 messages · Page 1 of 1 (latest)

narrow granite
#

you saw the title, if you have any questions about the details, shoot

narrow granite
#

you want the details?

rain quiver
#

If you're doing this from the server, then it's because Player scripts are only replicated on the client

narrow granite
#

even on client it doesnt work

#

im aint stupid

rain quiver
narrow granite
#

if i didint try anything i wouldnt come here

rain quiver
#

Damn bro chill

#

You'd be surprised at the amount of dumbasses that post here

narrow granite
# rain quiver Yeah

so basicaly i need to disable a script untill the character spawns in (aka clicks a button on the character selection screen) and when i try to make a path to the script (EVEN ON A LOCAL SCRIPT) the output says that Playerscripts ISNT REAL

rain quiver
rain quiver
narrow granite
rain quiver
#

StarterCharacterScripts

narrow granite
rain quiver
#

You're saying you need it to be disabled until the character spawns

narrow granite
rain quiver
#

But just once

narrow granite
#

also heres the function

#
function SpawnIn(plr: Player)
    
    if selectedChar then
         
        spawnRE:FireServer(selectedChar)
        plr.PlayerScripts:WaitForChild("Client").Enabled = true
        if camera:FindFirstChild("SELECTED CHARACTER") then
            camera["SELECTED CHARACTER"]:Destroy()
        end
        
        camera.CameraType = Enum.CameraType.Scriptable
        
        gui:Destroy()
    end
end```
narrow granite
rain quiver
#

Or another client

narrow granite
#

RAAAAAAAAA

rain quiver
#

I'm asking you if this function is only intended to work for the local player @narrow granite

narrow granite
rain quiver
#

Or if you're trying to access the Player scripts of another player that's not the local client

narrow granite
#

the player himselv

rain quiver
#

Alr

#

Try waiting on the player scripts

#

With WaitForChild

narrow granite
#

waitforchild for PlayerScripts?

#

good one but i already tried it

rain quiver
#

Uh

#

Can you maybe show me more code

narrow granite
rain quiver
#

Could it be that you might not be passing a player as an argument

narrow granite
narrow granite
#

so

#

ah foqe

rain quiver
narrow granite
#

script bad?

rain quiver
#

how do you expect

#

to get the player here

#

where anywhere would the player come from as an argument

narrow granite
#

wait no

#

add the argument in the SpawnIn fucntion at the end or smth?

rain quiver
#

MouseButton1Click gives you the x and y coordinate

#

nowhere does it get you the player lmao

rain quiver
#

😭

narrow granite
#

ok mane im kinda tired (idk why) so i dont really understand what ur saying rn

rain quiver
#

ok

true aurora
#

Can I ?

rain quiver
#

you know how functions work right

true aurora
#

Explain ?

rain quiver
#

can I try rq

true aurora
#

Yessir

rain quiver
#

but sure

narrow granite
rain quiver
#

and parameters and that stuff

narrow granite
rain quiver
#

alright

narrow granite
#

is there something wrong with me?

rain quiver
#

that's something very different

#

scope has to do with local variables

narrow granite
rain quiver
#

Right now, you're expecting the MouseButton1Click function to give you the player

#

which is not true

narrow granite
rain quiver
#

@true aurora you can explain lol idk hiw to to explain this

rain quiver
true aurora
#

Alright

rain quiver
#

what you need to do is make a variable for the player

true aurora
#

@narrow granite

#

Do you know what is a callback ?

narrow granite
true aurora
#

And do you know how events work ?

narrow granite
#

but in the hints it said when the GUI button is clicked with M1 btw

true aurora
#

Alright so when there is an event in the game you can some infos right ?

For example

Players.PlayerAdded => Event : a player is Added => you get the player who is added 
#

Do you get that ?

narrow granite
# true aurora Do you get that ?

yeah i kind of knew that from the getgo but how do i make it so the script enables when the player is in the map/clicked the spawn button

true aurora
#

I'm going into it

#

So basically some events give you informations, other dont

#

For example, child added gives you the child that has been added

#

But for mouse button 1 click

narrow granite
#

WAIT A SEC

true aurora
#

You don't get any informations

#

You get it ?

narrow granite
#

yeah

#

so i gotta like

#
Workspace.ChildAdded--...--wait a second
``` uhhhh
#

how do i specify which Child is added?

#

wait this is one of these things that are far more complex isnt it?

rain quiver
#

it's not lol

#

you either do

narrow granite
rain quiver
#

Instance:WaitForChild("name")

#

or

#

If you want to do something whenever any child is added to an instance:

narrow granite
rain quiver
#
Instance.ChildAdded:Connect(function(child: Instance)
  print(child.Name)
end)
narrow granite
rain quiver
#

This will run whenever a new child is added to the instance

narrow granite
#

RIGHT BEFORE YOU SHOWED IT TO ME

rain quiver
#

Can I show you rq what you expect to happen with your SpawnIn() function

rain quiver
#
local function SpawnIn(plr: Player) -- the ":" is just a type annotation, it doesn't mean you'll actually get a Player object
  print(plr.PlayerScripts) -- would work, *if the plr was a player*, but it's not
end


--mimicking what happens when you connect "SpawnIn" to "MouseButton1Click"
SpawnIn(1,2) -- first parameter is the x coordinate the button was clicked at, the second is the y
--You're trying to change a number into a player, which doesn't work AT ALL
rain quiver
#

Events might seem a bit mysterious, but really when you :Connect() a function, it just adds it to a list of functions that are called whenever the event is fired

narrow granite
#

wait the roblox AI was cooking

rain quiver
#

what

narrow granite
#

the AI coding thing gave a hint for the function to find the Player

true aurora
#

...

rain quiver
#

local plr = game.Players.LocalPlayer

narrow granite
rain quiver
#

yes that

#

it works

#

in a local script

narrow granite
rain quiver
#

you said it should only work for the local player

narrow granite
rain quiver
#

alr

#

does that work?

narrow granite
#

wait i was cooking with this

#

if child.ClassName == "Model"?

#

LADIES AND GENTLEMEN THE AI COOKED

#

(it copied and pasted some parts of this script here tho)

#

holly shit it worked

#

the roblox autocode ai worked

#

LETS GOOOOOO

empty vale
# narrow granite LETS GOOOOOO

why didnt u just use character added, executed the code and repeat wait() until character is not nil or whatever and disabled it. but its doesnt matter now that you solved it.