How do i fix this copying thingy

h
when i paste into the id of a accessory, it doubles for some reason and it might lag the game and ruin how the layered clothing would look like

this is the script that im using

the textbox script:

Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2024-03-05 Π² 15.36.10

local Replicated = game.ReplicatedStorage;
local Event = Replicated.AvatarEvent;

script.Parent.FocusLost:Connect(function()
	local Code = script.Parent.Text;
	if tonumber(Code) then
		Event:FireServer(Code)
	else
		Code = "USE NUMBERS!"
	end
end)

the handler script:

Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2024-03-05 Π² 15.36.45

local AvatarFrame = script.Parent.AvatarFrame;
local CodeText = AvatarFrame.Text;
local Replicated = game.ReplicatedStorage;
local Event = Replicated.AvatarEvent; -- Searches for event.

CodeText.FocusLost:Connect(function() -- If clicked enter or lost connection then.
	local Code = CodeText.Text -- Looks for code.
	if tonumber(Code) then -- If it's a number then.
		Event:FireServer(Code) -- Fires avatarevent with the inserted code.
	end
end)

can someone help me?

1 Like

try a debounce, or check if that layered clothing is not in the player yet before giving

1 Like

i kind of dont know alot about scripting, but the clothing wasnt on before, it just gives players an one item 2 times, i clicked of the gui to get that item

i kind of dont know how i can like write it i tried like

Event.FocusLost:connect(Event)

idk it didnt work, can u tell me?

Well so far I can see, you get the shirt twice because you’re firing the server twice, once in your Handler and once in your LocalScript. They are both doing the exact same thing. One of those scripts is redundant.

Also, if something lags it probably has to do with code that is ran on a ServerScript, so please show the function that is connected to the RemoteEvent.

i mean its not laggying but it may, but it have this in the serverscriptservice
and its name is β€œavatarhandler”

local Replicated = game.ReplicatedStorage; -- Searches replicatedstorage.
local Event = Instance.new("RemoteEvent"); -- Makes new event.
Event.Name = "AvatarEvent" -- Names the event.
Event.Parent = Replicated -- Places the event in replicatedstorage.

local InsertService = game:GetService("InsertService"); -- The roblox service to insert items from roblox catalog.

Event.OnServerEvent:Connect(function(Player, Code) -- If event has been fire then.
	for _,Item in pairs(InsertService:LoadAsset(Code):GetChildren()) do -- searches the items
			if Item:IsA("Accessory") then -- If it's a accesory then.
				Player.Character.Humanoid:AddAccessory(Item) -- Adds the hat.
		elseif Item:IsA("Shirt") then -- If it's a shirt then.
			if Player.Character:FindFirstChild("Shirt") then -- Looks if there is already a shirt.
				Player.Character.Shirt.ShirtTemplate = Item.ShirtTemplate -- Changes code to inserted code.
			else -- If not then.
				local ShirtClone	= Instance.new("Shirt"); -- Makes a new shirt cause there is no shirt yet.
				ShirtClone.Parent = Player.Character -- Adds the shirt to the character.
				ShirtClone.ShirtTemplate = Item.ShirtTemplate -- Changes code to inserted code.
			end
			elseif Item:IsA("Pants") then -- If it's a pants then.
			Player.Character.Pants.PantsTemplate = Item.PantsTemplate -- Changes texture to inserted code.
		elseif Item:IsA("Decal") then -- If it's a face then.
			Player.Character.Head.face.Texture = Item.Texture -- Changes code to inserted code.
		elseif Item:IsA("ShirtGraphic") then -- If it's a t-shirt then.
			if Player.Character:FindFirstChildOfClass("ShirtGraphic") then -- Finds for the t-shirt.
				Player.Character:FindFirstChildOfClass("ShirtGraphic").Graphic = Item.Graphic -- Changes code to inserted code.
			else -- If not then.
				local ShirtGraphicClone	= Instance.new("ShirtGraphic"); -- Adds new t-shirt.
				ShirtGraphicClone.Parent = Player.Character -- Adds to character.
				ShirtGraphicClone.Graphic = Item.Graphic -- Changes code to inserted code
			end
		end
	end
end)

print("Avatar Editor By Ewjadestinks!") -- Gives credits.

idk but i want to make that u get a chance to put into a id only once

btw i think i got those scripts out off youtune or roblox market a long time ago so idk who is β€œEwjadestinks”

oh wait it fixed when i deleted the β€œhandler” script, now it gives me the item once, ty for telling i wouldnt think about it lol, the item that is inserted rn is the boots


:heartpulse::heartpulse::heartpulse::heartpulse::heartpulse::heartpulse::heartpulse: ty again

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.