Getting Player for Attribute

Hello!

In a ServerScript, I have implemented attributes created in the Player to determine whether they are playing a game or not. How can I get the Player who interacted with the game to check the value of their “playinggame” attribute? [player:GetAttribute(“playinggame”)]

local function onClick(playing)
	if gameinfo.State.Value == "IDLE" and gameinfo.TicketsWon.Value <= 0 and player:GetAttribute("playinggame") == false then
		--Code
	end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

Thanks! :slight_smile:

Try this code:

local function onClick(player)
    local playing=player:GetAttribute("playinggame")
	if gameinfo.State.Value == "IDLE" and gameinfo.TicketsWon.Value <= 0 and playing == false then
		
	end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

The mouseclick event for click detectors always have a player parameter by default

Is there a way to also keep the “playing” parameter? It’s needed for code in the function.

Like this?

local function onClick(player, playing)

there is but you got to connect the onclick function within the mouseclick function

local function onClick(player,playing)
	if gameinfo.State.Value == "IDLE" and gameinfo.TicketsWon.Value <= 0 and player:GetAttribute("playinggame") == false then
	end
end

script.Parent.ClickDetector.MouseClick:connect(function(player)
      local playing= true
      onClick(player,playing)
end

This gets set to something somewhere else in the code, which I’m trying to figure out.

It might represent the player.

local a = playing.leaderstats:FindFirstChild(gameinfo.Currency.Value) -- A line in the code.

ok cool yeah i just made the playing variable a random default value