Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make an uniform GUI for an police vest?

Hello! I made a police vest for my roleplay game but. I want a GUI so players can put it on with just one button so they do not have to walk over a uniform giver or something can someone help me with this? (The vest is made of parts and unions and meshparts)

Greetings Mexx.

2 answers

You should use remote events and stuff. So when player clicks the button, it fires and attaches suit to player. Here is the script I would use: local script inside button

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)

script in scriptserverstorage:


game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
if not player.Character then
    print("waiting for character")
    player.CharacterAdded:wait();
    char = player.Character
else
    char = player.Character
end
--script that attaches things to player
end)

1 comment

0

ServerScriptService*

Please don't make requests on Scripting Helpers. Instead, attempt to do this yourself, and come back if you are having issues with your code. Your question should usually contain code. I'm feeling nice though, so I'll explain how this works step-by-step:

First we'll have our TextButton inside a ScreenGui, which is in the StarterGui. In the button, we'll make a LocalScript. To put clothing on the player's character, we'll have to use a RemoteEvent to communicate with the server, because it needs to perform the action. This will be the local script's content:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("RemoteEvent")
local button = script.Parent

button.MouseButton1Click:Connect(function()
   Remote:FireServer()
end)

This is great. Everytime the button is clicked, a remote event will be fired. Now, all we have to do is set up the server's action in response to the remote. Put this ServerScript in the ServerScriptService:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = Instance.new("RemoteEvent")
Remote.Parent = ReplicatedStorage
-----
local ShirtId = "rbxassetid://YourShirtIdHere"
local PantsId = "rbxassetid://YourPantsIdHere"

Remote.OnServerEvent:Connect(function(player)
   local Shirt = player.Character:FindFirstChildOfClass("Shirt")
   local Pants = player.Character:FindFirstChildOfClass("Pants")
   if Shirt then
      Shirt.ShirtTemplate = ShirtId
   else
      Shirt = Instance.new("Shirt")
      Shirt.ShirtTemplate = ShirtId
      Shirt.Parent = player.Character
   end
   if Pants then
      Pants.PantTemplate = PantsId
   else
      Pants = Instance.new("Pants")
      Pants.PantsTemplate = PantsId
      Pants.Parent = player.Character
   end
end)

In this script, we listen for the remote event to be fired. If it is, we scan the player's character for shirt and pants. If they exist, we simply edit their respective templates. Otherwise, we make new ones and do the same.


##Resources:

Remote Events


##Accept and upvote if this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.