PlayerAdded doesn't work in studio

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
  • I want to refer to a player in a ServerScript Using PlayerAdded event
  1. What is the issue?
  • The event just won’t run at all.
  1. What solutions have you tried so far?
  • I’ve looked up on the forum and saw someone said PlayerAdded event wont work in studio but will in the main game
  • I’m trying to find another way to refer to a Player in ServerScripts
local Players = game:GetService("Players")
local plr
Players.PlayerAdded:Connect(function(player)
	print("h")
	plr = player
end)
local Players = game:GetService("Players")

function PlayerJoined(Player)
    --Do stuff
end

Players.PlayerAdded:Connect(PlayerJoined)
for _, Player in ipairs(Players:GetPlayers()) do
    task.spawn(PlayerJoined, Player)
end
2 Likes

Where exactly is your script placed? Is your script executed on the game start? Double check if your script is a Module script or Server script.

Hello, PlayerAdded is working on studio Try this:

  1. Chek if you’re script is On ServerScriptService if it’s on ServerStorage it will not work.
  2. Check if you’re script is not Disabled.
  3. Check if there are others script that can delete it when you run the game.

Try putting a semi colon after the “local plr” so it should be “local plr;”
And if it isn’t already make sure it’s a server script in server script service.

If PlayerAdded isn’t working then this shouldn’t work right?

The script is in a tool, which is in StaterPack

Why would PlayerAdded not be working?

So is the script inside the tool a localscript or a normal script?

Normal and also if i use your method, do i have to do all of my scripting inside of the function

No no that script is for serverscriptservice. Right now you want to get the player for a tool. give me a sec

1 Like

If you use normal script

local Player = script:FindFirstAncestorWhichIsA("Player") 

if Player then

end

LocalScript

local Player = game.Players.LocalPlayer
1 Like

in some of my other project, i used the ooga booga cave man method which is

script.Parent.Parent.Parent 

which worked, but i dont think its efficient

Probably Starterpack get loaded after the player join, so the event will not fire, you should put that script inside ServerScriptService


it did work ingame

Studio usualy take some more time to load, and thats probably leads to what I just told you in my previous answer

Screenshot_1
It did print out oof but it’s hard to see since your video is cropped

1 Like

oh, i’m sorry, i didnt noticed the print

1 Like