Advertisement
V5_Beyonder

outfit changer

May 19th, 2024
2,700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. -- Script for a GUI button to change a player's outfit in Roblox
  2.  
  3. -- Function to change the player's outfit
  4. local function changeOutfit(player, shirtId, pantsId)
  5. -- Check if the player has a character and if the character has a humanoid
  6. if player.Character and player.Character:FindFirstChild("Humanoid") then
  7. -- Create new shirt and pants objects
  8. local shirt = Instance.new("Shirt")
  9. local pants = Instance.new("Pants")
  10.  
  11. -- Set the shirt and pants asset IDs
  12. shirt.ShirtTemplate = "rbxassetid://" .. shirtId
  13. pants.PantsTemplate = "rbxassetid://" .. pantsId
  14.  
  15. -- Find and remove any existing shirt or pants
  16. for _, item in pairs(player.Character:GetChildren()) do
  17. if item:IsA("Shirt") or item:IsA("Pants") then
  18. item:Destroy()
  19. end
  20. end
  21.  
  22. -- Parent the new shirt and pants to the player's character
  23. shirt.Parent = player.Character
  24. pants.Parent = player.Character
  25. end
  26. end
  27.  
  28. -- Connect the button click event to the changeOutfit function
  29. script.Parent.ChangeOutfitButton.MouseButton1Click:Connect(function()
  30. -- Get the local player
  31. local player = game.Players.LocalPlayer
  32.  
  33. -- Define the asset IDs for the new outfit
  34. local newShirtId = "123456789" -- Replace with your shirt asset ID
  35. local newPantsId = "987654321" -- Replace with your pants asset ID
  36.  
  37. -- Call the function to change the outfit
  38. changeOutfit(player, newShirtId, newPantsId)
  39. end)
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement