I want the player to go through the wall if they are admins or up in my group.
The issue is that I’m getting this error:
GetRankInGroup is not a valid member of Part "Workspace.LMVM2041.Nerd Glasses.Handle"
Code
local groupid = 8001185
script.Parent.Touched:Connect(function(Player)
if Player:GetRankInGroup(groupid) >= 150 then
script.Parent.CanCollide = false
wait(0.5)
script.Parent.CanCollide = true
else
print("Unauthorized player detected!")
end
end)
Touched would return the part that touched script.Parent. You need to get the Player from the part that was touched. You could try something like this:
local Players = game:GetService'Players'
local groupid = 8001185
script.Parent.Touched:Connect(function(touched)
-- get player from "touched.Parent" (player character in most cases)
local Player = Players:GetPlayerFromCharacter(touched.Parent)
-- if the part that touched didn't belong to a player's character, then do nothing
if not Player then return end
if Player:GetRankInGroup(groupid) >= 150 then
script.Parent.CanCollide = false
wait(0.5)
script.Parent.CanCollide = true
else
print("Unauthorized player detected!")
end
end)
It would be advised to call this locally instead. As @RipPBB_TUD already stated, users could cheat their way into the area by going in simultaneously with the user in the group since it’s server-sided.