We did try a script for skins changing as a local, and all is working Good, but we need to put on server script, for every one see it.
Any one can help? Thankss
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 12345-- Change to your Gamepass ID
local button = script.Parent.Parent.ShopSkyns.CloseSkyns
local player = game.Players.LocalPlayer
local frame = script.Parent.Parent.ShopSkyns
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
if hasPass then
frame.Visible = true
button.Rotation = 180
for i = 1, 10 do
frame.Position = UDim2.new(0.3, 0, -i/120 + 0.4 , 0)
wait(0.01)
end
else
local purchasePrompt = MarketplaceService:PromptGamePassPurchase(player, GamepassID)
purchasePrompt.Completed:Connect(function(purchaseSuccess)
if purchaseSuccess then
frame.Visible = true
for i = 1, 10 do
frame.Position = UDim2.new(0.02, 0, -i/120 + 0.5 , 0)
wait(0.01)
end
else
frame.Visible = false
button.Rotation = 180
--end
end
end)
end
end)
You are trying to get the local player on the server, which returns nil
But the MouseButton1Click event does return the player
Try this:
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 12345 -- Change to your Gamepass ID
local button = script.Parent.Parent.ShopSkyns.CloseSkyns
local frame = script.Parent.Parent.ShopSkyns
script.Parent.MouseButton1Click:Connect(function(player)
local hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
if hasPass then
frame.Visible = true
button.Rotation = 180
for i = 1, 10 do
frame.Position = UDim2.new(0.3, 0, -i/120 + 0.4 , 0)
wait(0.01)
end
else
local purchasePrompt = MarketplaceService:PromptGamePassPurchase(player, GamepassID)
purchasePrompt.Completed:Connect(function(purchaseSuccess)
if purchaseSuccess then
frame.Visible = true
for i = 1, 10 do
frame.Position = UDim2.new(0.02, 0, -i/120 + 0.5 , 0)
wait(0.01)
end
else
frame.Visible = false
button.Rotation = 180
end
end)
end
end)
You should handle this with 2 different scripts, 1 for server-side marketplace, and the other for receiving the user’s input, this would look something like this:
--LocalScript
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketPlaceService")
local Player = Players.LocalPlayer
local Button = script.Parent
Button.MouseButton1Click:Connect(function()
if MarketPlaceService:UserOwnsGamepassAsync(Player.UserId, <GAMEPASS ID HERE>) then
-- The player owns the gamepass
else
-- The player does not own the gamepass
<some remote event>:FireServer()
end
end)
--Server Script
local MarketPlaceService = game:GetService("MarketPlaceService")
local Event = <some event>
Event.OnServerEvent:Connect(function(Player)
MarketPlaceService:PromptGamepassPurchase(Player, <gamepass id>)
MarketPlaceService.ProcessReceipt = function()
-- Handle gamepass purchase
end
end)
Hello, I have tried to adapt the script as best we could, it gives me an error in:
‘MarketPlaceService’ is not a valid Service name
I understand how sending the event (ReplicatedStorage SkinsEvent) sends the information from the event to collect the SSService script.
but with our humble wisdom, since it is less difficult for us to see it, we keep trying!!
--Local Script
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketPlaceService")
local Player = Players.LocalPlayer
local Button = script.Parent.Parent.ShopSkyns.CloseSkyns
local Frame = script.Parent.Parent.ShopSkyns
Button.MouseButton1Click:Connect(function()
if MarketPlaceService:UserOwnsGamepassAsync(Player.UserId, 651733501) then
Frame.Visible = true
for i = 1, 10 do
Frame.Position = UDim2.new(0.3, 0, -i/120 + 0.4 , 0)
wait(0.01)
end
else
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.SkinsEvent:FireServer()
end)
end
end)
--server script en ServerScriptService
local MarketPlaceService = game:GetService("MarketPlaceService")
local Event =game.ReplicatedStorage.SkinsEvent
local Button = script.Parent.Parent.StarterGui.SkynsShop.SkynShopbutton
local Frame = script.Parent.Parent.StarterGui.SkynsShop.ShopSkyns
Event.OnServerEvent:Connect(function(Player)
MarketPlaceService:PromptGamepassPurchase(Player, 651733501)
MarketPlaceService.ProcessReceipt = function()
game.purchasePrompt.Completed:Connect(function(purchaseSuccess) -- purchaseSuccess is a boolean
if purchaseSuccess then
Frame.Visible = true
for i = 1, 10 do
Frame.Position = UDim2.new(0.02, 0, -i/120 + 0.5 , 0)
wait(0.01)
end
else
Frame.Visible = false
end
end)
end
end)
Fire a RemoteEvent to the server and change it there too.
Example Code:
Client Side:
local changeSkinRemote = game.ReplicatedStorage.ChangeSkin -- Your path to the remote goes here.
-- Fire the remote when the desired action happens,
-- I don't fully know what you're trying to achieve with rotating a button and other stuff but when it happens, here it is, it fires.
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 12345-- Change to your Gamepass ID
local button = script.Parent.Parent.ShopSkyns.CloseSkyns
local player = game.Players.LocalPlayer
local frame = script.Parent.Parent.ShopSkyns
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
if hasPass then
-- Here, insert what you're trying to fire the server with.
changeSkinRemote:FireServer()
frame.Visible = true
button.Rotation = 180
for i = 1, 10 do
frame.Position = UDim2.new(0.3, 0, -i/120 + 0.4 , 0)
wait(0.01)
end
else
local purchasePrompt = MarketplaceService:PromptGamePassPurchase(player, GamepassID)
purchasePrompt.Completed:Connect(function(purchaseSuccess)
if purchaseSuccess then
-- Here, insert what you're trying to fire the server with.
changeSkinRemote:FireServer()
frame.Visible = true
for i = 1, 10 do
frame.Position = UDim2.new(0.02, 0, -i/120 + 0.5 , 0)
wait(0.01)
end
else
frame.Visible = false
button.Rotation = 180
--end
end
end)
end
end)
Server Side:
local changeSkinRemote = game.ReplicatedStorage.ChangeSkin -- Your path to the remote goes here.
changeSkinRemote.OnServerEvent:Connect(function()
-- Your skin changing logic goes here.
end)
Thank you it works !!! It’s perfect!! Script… but still we don’t see each other’s skins. … How we do that?
--local script
local changeSkinRemote = game.ReplicatedStorage.SkinsEvent -- Your path to the remote goes here.
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 123456-- Change to your Gamepass ID
local player = game.Players.LocalPlayer
local frame = script.Parent.Parent.ShopSkyns
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
if hasPass then
-- Here, insert what you're trying to fire the server with.
changeSkinRemote:FireServer()
frame.Visible = true
for i = 1, 10 do
frame.Position = UDim2.new(0.3, 0, -i/120 + 0.4 , 0)
wait(0.01)
end
else
local purchasePrompt = MarketplaceService:PromptGamePassPurchase(player, GamepassID)
purchasePrompt.Completed:Connect(function(purchaseSuccess)
if purchaseSuccess then
-- Here, insert what you're trying to fire the server with.
changeSkinRemote:FireServer()
frame.Visible = true
for i = 1, 10 do
frame.Position = UDim2.new(0.02, 0, -i/120 + 0.5 , 0)
wait(0.01)
end
else
frame.Visible = false
--end
end
end)
end
end)
We should if we understood nice… The script with button conecction on this one?
-- ServerScriptService
local changeSkinRemote = game.ReplicatedStorage.SkinsEvent -- Your path to the remote goes here.
changeSkinRemote.OnServerEvent:Connect(function()
-- Your skin changing logic goes here.
end)