Quite simple, this script doesn’t print the players name
local groupid = nil -- For now at least xD
local allowedRank = 1
function onClicked(plr)
print(plr.Name .. "Has clicked!" )
local rank = plr:GetRankInGroup(groupid)
if rank < allowedRank then
return
end
end
script.Parent.MouseButton1Click:Connect(onClicked)
Done some research same issue, unless I wrote something wrong, not sure… thoughts?
As someone already pointed out, MouseButton1Click doesn’t pass the player object. However, to access the player’s StarterGui from a server script, you need to have that specific player in some variable already anyways, so you could use that in your code to get the group rank.
if this is inside an UI you should be using a localscript, and then you can get the player like so
local Players = game:GetService("Players")
local Player = game.Players.LocalPlayer
local groupid = 1
function onClicked()
print(Player.Name .. "Has clicked!" )
local rank = Player:GetRankInGroup(groupid)
end
script.Parent.MouseButton1Click:Connect(onClicked)
if this is inside a ClickDetector then you can pass the player as the argument
local groupid = 1
function onClicked(Player)
print(Player.Name .. "Has clicked!" )
local rank = Player:GetRankInGroup(groupid)
end
script.Parent.MouseClick:Connect(onClicked)