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

How Do I call a Function based on when A player joins the game?

So I'm working on learning the scoreboard system. I'm at the point where I have built a function that creates a leaderstats model and a score intvalue. The problem is this: currently the code is being triggered when the game starts and what I'd rather do is have it be called when a player joins the game. So How do I call a function when a player joins the game?

1 comment

1

Use game.Players.PlayerAdded:Connect()

1 answer

like

 game.Players.PlayerAdded:Connect(function(player)
	local ls = Instance.new("Folder",player)
	ls.Name = "leaderstats"
	
	local v1= Instance.new("IntValue",ls)
	v1.Name = "yourvalue1"
	
	local v2= Instance.new("IntValue",ls)
	v2.Name = "yourvalue2"
	
	
	player.CharacterAdded:Connect(function(char) -- This just sets the value 
		player.yourvalue1.Value = 1234
		player.yourvalue2.Value = 12345	
		
	end)
end)

?

2 comments

0

YES!! from what I can see that will be excatly what I need thanks!

0

:P

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