Good morning, in the end we have found the solution after trying and with the super help offered, we finally managed to connect the scripts:
FIRST SCRIPT, the marketplace with the GUI opening button, Skins (with the script provided.
--LOCAL SCRIPT FOR BUTTON OPEN GUI IF YOU HAVE THE GAME PASSID
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) --THIS FUCTION CLICK TO BUTTON
if hasPass then -- IF YOU HAVE THE PASS SHOW THE GUI
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)
SECOND SCRIPT
the server script that receives the event for the GUI buttons, and their textures.
--SERVER CRIPT ON SERVERCRIPTSERVICE
local changeSkinEvent = game.ReplicatedStorage.ChangeSkinEvent
changeSkinEvent.OnServerEvent:Connect(function(player, imageButton)
-- Change the texture of the character's parts on workspace.Player.character
for _, part in ipairs(player.Character:GetDescendants()) do
if part:IsA("MeshPart") then
part.TextureID = imageButton.Image
end
end
end)
THIRD SCRIPT
The button script that sends the event order to change the skin, and can be seen by all users, regardless of the user (custom)
--localScript ON IMAGE BUTTON
local imageButton = script.Parent
local changeSkinEvent = game.ReplicatedStorage.ChangeSkinEvent --PICK UP THE EVENT
local player = game.Players.LocalPlayer
local function changeAvatar() --CONECT EVENT ON CLICK BUTTON AND SEND THE SKIN IN TO THE SERVER
changeSkinEvent:FireServer(imageButton)
end
imageButton.MouseButton1Click:Connect(changeAvatar)
Thank you very much for your help , it has been great, and it has helped us better understand the change from local to server, thank you very much