I want to make a part that allows gamepass owners or a certain rank to be able to go through it, but when I scripted it I get some errors, I'm an intermediate scripter.
Here is the script I made:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if marketplace:UserOwnsGamePassAsync(plr.UserId, gamepassidhere) or
plr:GetRankInGroup(groupid) >= 0 then
script.Parent.CanCollide = false
wait(2)
script.Parent.CanCollide = true
end
end
end)

4 comments
changing it in server will change it for everyone
you probably shouldn't give entire scripts.
Also, there's no need to put it in StarterGui.
I’m not a good scripter yet ok? Lol