Does anyone have a fix for a script that teleports a person to a specific place when they touch a specific brick if they have a specific game pass? And if they don’t have the game pass, prompt them to buy it.
I had one that worked (I thought) but it breaks when someone goes through it.
My code:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local mps = game:GetService("MarketplaceService")
local gamepassID = 0
local placeID = 0
local gamepassOwned = false
pcall(function()
gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
end)
humanoid.Touched:Connect(function(touchedPart)
if gamepassOwned == true then
end
if touchedPart == game.Workspace.TP then
if gamepassOwned == true then
game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
end
mps:PromptGamePassPurchase(plr, gamepassID)
end
end)
mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)
if not purchaseSuccess then return end
if playerPurchased == plr and purchasedID == gamepassID then
gamepassOwned = true --where it might be going wrong
game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
end
end)
Ok but do you have any idea why this only works for the 1st person to use it?
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local mps = game:GetService("MarketplaceService")
local gamepassID = 0
local placeID = 0
local gamepassOwned = false
pcall(function()
gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
end)
humanoid.Touched:Connect(function(touchedPart)
if gamepassOwned == true then
end
if touchedPart == game.Workspace.TP then
if gamepassOwned == true then
game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
end
mps:PromptGamePassPurchase(plr, gamepassID)
end
end)
mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)
if not purchaseSuccess then return end
if playerPurchased == plr and purchasedID == gamepassID then
gamepassOwned = true
game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
end
end)
This is for scripting support, not a place to ask for scripts. Plus, you didn’t provide any code, nor any errors you have, so you have to include that in the OP
Does anyone have a fix for a script that teleports a person to a specific place when they touch a specific brick if they have a specific game pass? And if they don’t have the game pass, prompt them to buy it.
I had one that worked (I thought) but it breaks when someone goes through it.
My code:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local mps = game:GetService("MarketplaceService")
local gamepassID = 0
local placeID = 0
local gamepassOwned = false
pcall(function()
gamepassOwned = mps:UserOwnsGamePassAsync(plr.UserId, gamepassID)
end)
humanoid.Touched:Connect(function(touchedPart)
if gamepassOwned == true then
end
if touchedPart == game.Workspace.TP then
if gamepassOwned == true then
game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
end
mps:PromptGamePassPurchase(plr, gamepassID)
end
end)
mps.PromptGamePassPurchaseFinished:Connect(function(playerPurchased, purchasedID, purchaseSuccess)
if not purchaseSuccess then return end
if playerPurchased == plr and purchasedID == gamepassID then
gamepassOwned = true --where it might be going wrong
game:GetService("TeleportService"):Teleport(placeID, game.Players.LocalPlayer)
end
end)
This is good. That would be a good edit to make @ShadowAlien98
I understand you added on your code later on but not including it in the OP gives me the right to assume that you are essentially asking for code. Category guidelines state to include code and your error