So, I'm trying to experiment with IsInGroup, GetRankInGroup, and GetRoleInGroup. But for some reason I can't seem to get any of them to work. I looked at tutorials and tried doing it myself, but still nothing. As shown below on line 4, the IsInGroup shows when a colon is added. So any explanation as to why this won't work?
local Player = game.Players.LocalPlayer function Touched(plr) if Player:IsInGroup(3713839) then print("Works!") end end script.Parent.Touched:Connect(Touched)
The issue with your script is that you cannot get the player using game.Players.LocalPlayer in a ServerScript and you cannot use the Touched Function in a local script. ROBLOX came up with a solution how you can get the player on a touched event using GetPlayerFromCharacter:
https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerFromCharacter
It essentially returns the player from the character.
You can put the ServerScript in a part.
-- function that runs when the part is touched. script.Parent.Touched:Connect(function(hit) -- variable to get the player from hit.Parent. local player = game.Players:GetPlayerFromCharacter(hit.Parent) --Checks if the player is in group and prints work. if player:IsInGroup(3713839) then print("Works!") end end)