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

Vip door that when a player touches it prompts the gamepass for everyone. Any solutions?

Asked by
xp5u 25
3 years ago
local plr = game.Players.LocalPlayer

if game.MarketplaceService:UserOwnsGamePassAsync(plr.UserId, 18133269) then
    local adoor = game.Workspace.GamepassDoor2
    adoor.Parent = game.Workspace.CurrentCamera
    adoor:Destroy()
else
    local door = game.Workspace:FindFirstChild("GamepassDoor2"):Clone()
    door.Parent = game.Workspace.CurrentCamera
    door.CanCollide = true
    door.Anchored = true
    door.CFrame = game.Workspace.GamepassDoor2.CFrame
    door.Touched:Connect(function()
        if game.MarketplaceService:UserOwnsGamePassAsync(plr.UserId, 18133269) ~= true then
            game.MarketplaceService:PromptGamePassPurchase(plr, 18133269)
        end
    end)
end

It is a localscript in starterpack

1 answer

Log in to vote
0
Answered by
RAFA1608 543 Moderation Voter
3 years ago
Edited 3 years ago

Hello. Have you considered searching in this site before asking a question, in order to see if your same question has been answered before?

Anyways, the script doesnt care whether it is you that touched the wall or someone else. To fix it, you need to check if the part is from the localplayer's character or not.

door.Touched:Connect(function(part) --the part that hit
    local player = game.Players.LocalPlayer --localplayer
    if part:IsDescendantOf(player.Character) then --checks if the part that hit the door is from the localplayer's character or not, therefore only prompting him
        game.MarketplaceService:PromptGamePassPurchase(plr, 18133269)
    end
end)

I hope this helps.

If you have any questions, feel free to ask them below.

0
Uh, so when I replace it from door.Touched to the end of the script it doesnt prompt the gamepass ui. Any suggestions? xp5u 25 — 3y
0
Does it give any errors? RAFA1608 543 — 3y
0
It says this: Error: (20,6) Syntax error: Expected 'end' (to close 'else' at line 7), got <eof>; did you forget to close 'then' at line 16? xp5u 25 — 3y
0
Apparently, you forgot to add an "end" to close the statement "else at line 7", but the lua interpreter found the end of the script instead. RAFA1608 543 — 3y
View all comments (4 more)
0
Add a "end" at the end of the script and itll work fine. I guess. RAFA1608 543 — 3y
0
I'm stuck on where to put another end? Can you help me? Thanks! xp5u 25 — 3y
0
RIGHT I c now, thanks xp5u 25 — 3y
Ad

Answer this question