Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a gamepass and/or group door?

Asked by 3 years ago

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)

2 answers

Log in to vote
0
Answered by
iivSnooxy 248 Moderation Voter
3 years ago

Hii, here’s the Group Rank Door script!

--PUT THIS SCRIPT UNDER STARTERGUI!!!--

local Player = game.Players.LocalPlayer
local doorPart = game.Workspace.Door.Door
local groupId = --GROUPIDHERE
local minimumRank = 2

if Player:GetRankInGroup(groupId) >= minimumRank then
    print("Player is at or above minimum rank")
    doorPart.CanCollide = false
else
    print("Player is below minimum rank")
    doorPart.CanCollide = true
end
0
changing it in server will change it for everyone kkfilms_1 68 — 3y
0
you probably shouldn't give entire scripts. sngnn 274 — 3y
0
Also, there's no need to put it in StarterGui. sngnn 274 — 3y
0
I’m not a good scripter yet ok? Lol iivSnooxy 248 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I suggest using a RemoteEvent in Replicated Storage

ServerScript:

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 
          if plr:GetRankInGroup(groupid) >= 0 then
             game.ReplicatedStorage.RemoteEvent:FireClient(plr)
         end
    end
end)

Local Script in StarterPlayerScripts:

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
    local door = workspace:FindFirstChild(“door”,true) —Change this to the name of the door
    door.CanColliide = false 
    wait(2)
    door.CanCollide = true
end)

If it’s fine, can you elaborate on the errors so i can adjust the script accordingly?

0
 For ServerScript, lines 5th has a error with the "if" and for Local Script, it says "OnServerEvent can only be used on the server"  ReaILazy -9 — 3y
0
sorry i changed it kkfilms_1 68 — 3y

Answer this question