Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

8 comments

0

Uh, so when I replace it from door.Touched to the end of the script it doesnt prompt the gamepass ui. Any suggestions?

0

Does it give any errors?

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?

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.

0

Add a "end" at the end of the script and itll work fine. I guess.

0

I'm stuck on where to put another end? Can you help me? Thanks!

0

RIGHT I c now, thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.