Issue checking player

Code is pretty self-explanatory, checking if localplayer is a member of the group above a certain rank, and if they are the click detector for the player specifically will have the max activation distance of 12 and if the player is not in the group the activation distance for them is 0. Not working properly, I think the issue is trying to get the localplayer, but that is just a guess.

local player = game.Players.LocalPlayer

    if player:GetRankInGroup(9763233) >= 25 then
    	script.Parent.MaxActivationDistance = 12
    else
    	script.Parent.MaxActivationDistance = 0
    end

I think you have to put it inside StarterPlayerScripts

Is your ClickDetector in Workspace? LocalScripts don’t run there.

1 Like

I’m erm, looking at this here and I don’t think you can do it like that

So you’d need to put that LocalScript somewhere else (In StarterPack preferably) and define the ClickDetector/ProximityPrompt as well:

local Player = game.Players.LocalPlayer
local Something = workspace.ClickDetector

if Player:GetRankInGroup(9763233) >= 25 then
    Something.MaxActivationDistance = 12
else
    Something.MaxActivationDistance = 0
end
1 Like
game.Players.PlayerAdded:Connect(function(player)
if player:GetRankInGroup(9763233) >= 25 then
    	script.Parent.MaxActivationDistance = 12
    else
    	script.Parent.MaxActivationDistance = 0
    end
end)

Maybe this works. Let me know if it won’t work :slight_smile:

What’s the purpose of this? The point here is that the ClickDetector shouldn’t be clickable for those not above the Rankid of 25. There’s no point of the PlayerAdded if it’s local and if it’s server it won’t work for everyone.

I have multiple doors to do this with though.

Actually I got a fix for it nevermind

You could loop through all the ClickDetectors then I guess with this?

for _, Detector in pairs(workspace:GetDescendants()) do
    if Detector:IsA("ClickDetector") then
        Detector.MaxActivationDistance = 12
    end
end

Thank all of you for your answers I figured out a fix for it.