Getting player ID

So I want to make a safe guard so only the owner of the tycoon can reset the values but it seems like buttons can’t retrieve player info? Any way I can do this

reset.MouseButton1Click:Connect(function(player)

if player.UserId == tycoon:GetAttribute("UserId") then
	fluidJumppower.Value = 0
	stability.Value = 0
end

end)

MouseButton1Click returns the x and y of the players mouse. Simply use game.Players.LocalPlayer.UserId

1 Like

Assuming its a local script, we can get the local player:

reset.MouseButton1Click:Connect(function()

if game.Players.LocalPlayer.UserId == tycoon:GetAttribute("UserId") then
	fluidJumppower.Value = 0
	stability.Value = 0
end
end)

function(player), roblox doesn’t give the player in a Object they clicked on the client.

1 Like

Ahhh thanks for the clarification!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.