Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script for a GUI button to change a player's outfit in Roblox
- -- Function to change the player's outfit
- local function changeOutfit(player, shirtId, pantsId)
- -- Check if the player has a character and if the character has a humanoid
- if player.Character and player.Character:FindFirstChild("Humanoid") then
- -- Create new shirt and pants objects
- local shirt = Instance.new("Shirt")
- local pants = Instance.new("Pants")
- -- Set the shirt and pants asset IDs
- shirt.ShirtTemplate = "rbxassetid://" .. shirtId
- pants.PantsTemplate = "rbxassetid://" .. pantsId
- -- Find and remove any existing shirt or pants
- for _, item in pairs(player.Character:GetChildren()) do
- if item:IsA("Shirt") or item:IsA("Pants") then
- item:Destroy()
- end
- end
- -- Parent the new shirt and pants to the player's character
- shirt.Parent = player.Character
- pants.Parent = player.Character
- end
- end
- -- Connect the button click event to the changeOutfit function
- script.Parent.ChangeOutfitButton.MouseButton1Click:Connect(function()
- -- Get the local player
- local player = game.Players.LocalPlayer
- -- Define the asset IDs for the new outfit
- local newShirtId = "123456789" -- Replace with your shirt asset ID
- local newPantsId = "987654321" -- Replace with your pants asset ID
- -- Call the function to change the outfit
- changeOutfit(player, newShirtId, newPantsId)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement