Im trying to make a script that makes you be able to “teleport to top” in a obby type game. To cheat your way up using robux.
The mouse doesnt change into a finger when hovering over the part and clicking it does nothing.
Locations:
local part = script.Parent
local productId = 1365882498
local teleportLocation = Vector3.new(55, 52.85, -24)
part.ClickDetector.MouseClick:Connect(function(player)
local success, message = game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
if success then
local character = player.Character
character:MoveTo(teleportLocation)
else
print(message)
end
end)
instead of teleporting the whole character, try using the the humanoid root part that controls it position. This script should work:
local part = script.Parent
local productId = 1365882498
local teleportLocation = Vector3.new(55, 52.85, -24)
part.ClickDetector.MouseClick:Connect(function(player)
local success, message = game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
if success then
local character = player.Character.HumanoidRootPart
character:MoveTo(teleportLocation)
else
print(message)
end
end)
I just wanted to quickly say that the mouse not changing into a finger is a bug going around with ClickDetectors right now.
Clickdetectors by default should change the cursor int oa finger, even without scripts.
local part = script.Parent
local productId = 1365882498
local teleportLocation = Vector3.new(55, 52.85, -24)
part.ClickDetector.MouseClick:Connect(function(player)
local success, message = pcall(function()
game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)
end)
if success then
local character = player.Character
character:MoveTo(teleportLocation)
else
print(message)
end
end)
I have no clue what everyone else here is talking about lol. You can’t pcall :PromptProductPurchase because it doesn’t return anything. It’s just used to prompt the purchase, you need to actually have logic on the server to handle purchase requests.
Also, local scripts inside workspace do not run.
I’ll give you a step by step guide to fix your problem.
Replace your LocalScript with a normal script and paste this inside:
--//Services
local MarketplaceService = game:GetService("MarketplaceService")
--//Variables
local Part = script.Parent
--//Controls
local ProductId = 1365882498
--//Functions
Part.ClickDetector.MouseClick:Connect(function(player)
MarketplaceService:PromptProductPurchase(player, ProductId)
end)
Add a new script in ServerScriptService and paste this inside:
--//Services
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
--//Tables
local productFunctions = {
[1365882498] = function(player)
local character = player.Character
if character then
character:PivotTo(CFrame.new(Vector3.new(55, 52.85, -24)))
end
end,
}
--//Functions
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
local Function = productFunctions[receiptInfo.ProductId]
local success, result = pcall(Function, player)
if not success or not result then
warn("Error occurred while processing a product purchase")
print("\nProductId:", receiptInfo.ProductId)
print("\nPlayer:", player)
return Enum.ProductPurchaseDecision.NotProcessedYet
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Everything should work now, if there are any errors please tell me them and I will fix it.