I have a piece of code that I want to print out when they press the “Golden Button” so I know who presses it. I read another post and I was able to fix my mistake, and it is printing in the console, but it is only printing “nil” instead of the player’s name. Any Ideas as to where I can fix it?
local groupId = 5879349
local minrank = 253
local golden = game.Workspace.judgetable.Table.goldenbutton
local chloe = game.Workspace.judgetable.Table.chloebutton
local ben = game.Workspace.judgetable.Table.benbutton
local donut = game.Workspace.judgetable.Table.donutbutton
local beems = game.Workspace.judgetable.Table.beemsbutton
local beemsstar = game.Workspace.judgetable.Stars.beanstar
local donutstar = game.Workspace.judgetable.Stars.donutstar
local benstar = game.Workspace.judgetable.Stars.benstar
local chloestar = game.Workspace.judgetable.Stars.chloestar
local starmodel = game.Workspace.judgetable.Stars
local localplayer = game.Players.LocalPlayer
– x buttons –
chloe.ClickDetector.MouseClick:Connect(function(player)
if player:GetRankInGroup(groupId) >= minrank then
print(“chloe button pressed”)
chloestar.BrickColor = BrickColor.new(“Really red”)
end
end)
ben.ClickDetector.MouseClick:Connect(function(player)
if player:GetRankInGroup(groupId) >= minrank then
print(“ben button pressed”)
benstar.BrickColor = BrickColor.new(“Really red”)
end
end)
donut.ClickDetector.MouseClick:Connect(function(player)
if player:GetRankInGroup(groupId) >= minrank then
print(“donut button pressed”)
donutstar.BrickColor = BrickColor.new(“Really red”)
end
end)
beems.ClickDetector.MouseClick:Connect(function(player)
if player:GetRankInGroup(groupId) >= minrank then
print(“donut button pressed”)
beemsstar.BrickColor = BrickColor.new(“Really red”)
end
end)
– golden buzzer –
golden.ClickDetector.MouseClick:Connect(function(player)
if player:GetRankInGroup(groupId) >= minrank then
print(localplayer, “has pressed the button”)
for num, child in pairs(starmodel:GetChildren()) do
if child:IsA(‘UnionOperation’) then
child.BrickColor = BrickColor.new(“Bright yellow”)
end
end
end
end)
I only really care about the golden buzzer script, but I could implement it into the other persons buttons aswell. For context as well, this game is a Got Talent type game.
That means that you’re probably executing this code on the Server. You’re going to need to add a parameter (plr or player, preferably) to the MouseClick event, and do plr.Name.
If this is in a LocalScript (as you are using LocalPlayer), then change the LocalPlayer in this section with the player parameter in the function:
golden.ClickDetector.MouseClick:Connect(function(player)
if player:GetRankInGroup(groupId) >= minrank then
print(player, “has pressed the button”)
for num, child in pairs(starmodel:GetChildren()) do
if child:IsA(‘UnionOperation’) then
child.BrickColor = BrickColor.new(“Bright yellow”)
end
end
end
end)
Try this and see if it works. If not, then I recommend putting this section in a regular script and use a RemoteEvent to communicate with the client if you really need this to be client-sided.
(Well, it looks like you fixed it, but I’ll still post it since I think it is still useful).