Hi, I was making a morph for players who have purchased a game pass to my game.
When I step on the button, the morph is working correctly for me, but when someone else who does not own the game pass steps on the button, they will not morph, but I would like it to prompt them to buy the game pass.
I have tried to use PromptPurchase and PromptGamePassPurchase and neither work nor throw any errors.
Here is the script I am using for the button that you step on:
local mps = game:GetService("MarketplaceService")
local gamepass = 6832138
local db = false
local Players = game:GetService("Players")
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if mps:UserOwnsGamePassAsync(player.UserId, gamepass) then
if hit.Parent:FindFirstChild("Humanoid") ~= nil and db == false then
print("morph")
if hit.Parent:findFirstChild("Helmet") ~= nil then
hit.Parent:findFirstChild("Helmet"):Destroy()
end
if hit.Parent:findFirstChild("Chest") ~= nil then
hit.Parent:findFirstChild("Chest"):Destroy()
end
if hit.Parent:findFirstChild("Leg1") ~= nil then
hit.Parent:findFirstChild("Leg1"):Destroy()
end
if hit.Parent:findFirstChild("Leg2") ~= nil then
hit.Parent:findFirstChild("Leg2"):Destroy()
end
if hit.Parent:findFirstChild("Arm1") ~= nil then
hit.Parent:findFirstChild("Arm1"):Destroy()
end
if hit.Parent:findFirstChild("Arm2") ~= nil then
hit.Parent:findFirstChild("Arm2"):Destroy()
end
db = true
local t = hit.Parent.Torso
hit.Parent.Head.face.Texture = "rbxassetid://23975520"
local mesh = game.ReplicatedStorage.Numbers.Zero
mesh:Clone().Parent = hit.Parent.Torso
t.Zero.Offset = Vector3.new(0,-1,0)
t.Zero.Scale = Vector3.new(.07,.062,.035)
hit.Parent["Left Arm"].Transparency = 1
hit.Parent["Left Leg"].Transparency = 1
hit.Parent["Right Arm"].Transparency = 1
hit.Parent["Right Leg"].Transparency = 1
hit.Parent.Head.BrickColor = BrickColor.new("Really black")
hit.Parent.Humanoid.MaxHealth = 500
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.MaxHealth
end
else
mps:PromptPurchase(player, gamepass)
end
wait(4)
db = false
end
end
script.Parent.Touched:Connect(onTouched)
I have been working on this all night and I am stuck at the very end. Please help.
Thank you.
