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

Can You Make A Gamepass To Allow You When You Press The Teleport Gui It Teleports You?

A Gamepass That When You Bought It Then It Allows You When You Press The Teleport Gui Then It Teleports You Functionally But When It's Not Bought Then The Teleport Will Not Work

Here Is My Code:

disabled = false
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if game.MarketplaceService:PlayerOwnsAsset(player,11274115) then
			script.Parent.MouseButton1Click:connect(function()
				if disabled == false then
					disabled = true
					end
					script.Parent.BackgroundColor3 = Color3.new(217, 0, 0)
					game.Workspace.Teleport.RemoteFunction:InvokeServer()
					wait(3)
					script.Parent.BackgroundColor3 = Color3.new(0, 154, 0)
					disabled = false
				end)
function onKeyPress(inputObject, gameProcessedEvent)
					if inputObject.KeyCode == Enum.KeyCode.Q then
						if disabled == false then
							disabled = true
							end
							script.Parent.BackgroundColor3 = Color3.new(217, 0, 0)
							game.Workspace.Teleport.RemoteFunction:InvokeServer()
							wait(3)
							script.Parent.BackgroundColor3 = Color3.new(0, 154, 0)
							disabled = false
						game:GetService("UserInputService").InputBegan:connect(onKeyPress)

2 comments

0

on line 6 when you start the if statement, it ends at line 8, meaning all the code below it will run regardless of weather disabled is false

0

yes you can

1 answer

Try using game:GetService("MarketplaceService"):PlayerOwnsAsset(idhere)

and if its nil it wont let them teleport

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