I have a script that prevents players that are not in a group from seeing the part, it doesn’t seem to work, any ideas?
local part = script.Parent
local groupId = 9500492
if game:GetService("RunService"):IsServer() then
warn("This script should be a LocalScript inside the part!")
return
end
local player = game:GetService("Players").LocalPlayer
local function checkGroup()
if player:GetRankInGroup(groupId) == 0 then
-- Player is NOT in the group, make the part invisible
part.LocalTransparencyModifier = 1 -- Fully invisible for them
else
-- Player is in the group, keep it visible
part.LocalTransparencyModifier = 0
end
end
checkGroup()
local scripts dont work if they are descendants of workspace
1 Like
also… why
if game:GetService("RunService"):IsServer() then
warn("This script should be a LocalScript inside the part!")
return
end
3 Likes
script will error anyways cuz you trying to mess with LocalPlayer on server + you can just look at the instance icon in the explorer to figure out is it a local script or a script
2 Likes
Fixed the group part for you:
local part = script.Parent
local groupId = 9500492
if game:GetService("RunService"):IsServer() then
warn("This script should be a LocalScript inside the part!")
return
end
local player = game:GetService("Players").LocalPlayer
local function checkGroup()
if not player:IsInGroup(groupId) then
-- Player is NOT in the group, make the part invisible
part.LocalTransparencyModifier = 1 -- Fully invisible for them
else
-- Player is in the group, keep it visible
part.LocalTransparencyModifier = 0
end
end
checkGroup()
if player:GetRankInGroup(groupId) == 0 then
was changed to if not player:IsInGroup(groupId) then
I didn’t test this, but it should work.
as @whiplash3r said, you can’t use local scripts in the workspace, so put this local script into StarterPlayer.StarterPlayerScripts
local part = game.workspace.part --the part
local player = game.Players.LocalPlayer
local GroupId = 9500492 --your group id
local function checkGroup()
if(player:IsInGroup(GroupId)) then
part.Transparency = 0
else
part.Transparency = 1
end
end
checkGroup()
i think localtransparencymodifier is for the better but yeah 
What exactly is the difference between regular transparency and localtransparencymodifier?
If you were going to change transparency using a server script globally…
it just hints more that its supposed to be clientside and preserves actual transparency
If you were going to change transparency using a server script globally…
it just hints more that its supposed to be clientside and preserves actual transparency
Yes, but changing the transparency from the client-side will achieve the same thing.
i never said localtransparencymodifier is better (oh wait i did) though i should’ve mentioned its my personal preference, oops.
2 Likes