Script stuck as client side, any way to make it server side?

I would like this to work as a uniform GUI for my group.

Problem: It is only working client side when I need everyone to see it.

local Player = game:GetService("Players").LocalPlayer

local Uniform = {}
Uniform.Shirt = "http://www.roblox.com/asset/?id=" 
Uniform.Pants = "http://www.roblox.com/asset/?id=" 



function AddUniform(P)
	
	
	local Character = P.Character
	
	
	repeat wait(0) until Character ~= nil
	
	
	for i,Object in next,Character:GetChildren() do
		
		
		if Object:IsA("Shirt") or Object:IsA("Pants") then
			
			
			Object:Destroy()
			
			
		end
		
		
	end
	
	
	local Shirt = Instance.new("Shirt",Character)
	
	
    Shirt.ShirtTemplate = Uniform.Shirt


    local Pants = Instance.new("Pants",Character)


    Pants.PantsTemplate = Uniform.Pants
end




local Bin = script.Parent


if Bin:IsA("TextButton") or Bin:IsA("ImageButton") then
	
	
	Bin.MouseButton1Down:connect(function()
		
		
		AddUniform(Player)
		
		
		wait()
		
		
		script.Parent.Parent.Parent:remove()
		
		
	end)
	
	
end

Setup:
image

Is it just that I need to make the local script a normal script?

The change is being made Locally by a LocalScript. Simply changing it to a regular script will not fix it however as LocalScripts are needed to detect userinput on your GUI.

Have the LocalScript fire some remote event then have a regular script listening to perform the uniform change on its behalf.

You should use :Destroy() instead of :remove().

Although it is possible to change this to a server script and have it work, it is not recommended. Fire a remote event when the button is clicked and have the server make the shirt whenever it is fired.

1 Like

This script is older than most Roblox players.

6 Likes