I need help getting this shirt changing script to work

Hello, so I’m a novice scripter and am trying to improvise a script that allows the player’s character to change clothing upon the pressing of a button, however I keep getting the error “Requested module experienced an erro while loading”. Below is what I’ve written so far for both the local script that is in the starter pack and the server script respectively.

local Userinput = game:GetService("UserInputService")
local Activated = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShirtChangeEvent = ReplicatedStorage.ShirtChangeEvent
local Cooldown = 5


Userinput.InputBegan:Connect(function(Input,Istyping)
	if Istyping then return
	elseif Input.Keycode== Enum.KeyCode.E then
		if not Activated then
			Activated = true
			ShirtChangeEvent:FireServer()
		end
		
	end
	
end)

ShirtChangeEvent.OnClientEvent:Connect(function()
	wait(Cooldown)
	Activated = false
	
end)

and the server script…

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShirtChangeEvent = ReplicatedStorage.ShirtChangeEvent

ShirtChangeEvent.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	Character:FindFirstChild("Shirt").ShirtTemplate = "rbxassetid://1484582952"
	ShirtChangeEvent:FireClient(Player)
	
end)

If I’m doing it completely wrong, please give me some pointers and guidelines to creating the script, thanks.

1 Like

Uh, hmm, maybe you could use humanoiddescription to change it?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShirtChangeEvent = ReplicatedStorage.ShirtChangeEvent

ShirtChangeEvent.OnServerEvent:Connect(function(Player)
	local Character = Player.Character
	local hum = Character:FindFirstChild("Humanoid")
if hum then --checks to see if we are loaded in--
local description = hum:GetAppliedDescription() -- gets the current description applied.
description.Shirt = 1484582952 -- sets the shirt to your id--
hum:ApplyDescription(description) -- applies it to the character--
end
end)

Test this out please, and tell me if it works.

I tried it but it didn’t work, I still got the same error message.

Thats not with the script, thats with some other script, there are no modules being loading with this.

I don’t have any other scripts running besides these 2 though, no free models or anything either.

Maybe try searching for require in all scripts by using Ctrl + Shift + F, If not either roblox failed to load something in, or you have a bad plugin.

Theres an issue with the localscript, so pressing e thing doesnt even work.

New localscript.

local Userinput = game:GetService("UserInputService")
local Activated = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShirtChangeEvent = ReplicatedStorage.ShirtChangeEvent
local Cooldown = 5


Userinput.InputBegan:Connect(function(Input,Istyping)
	if Istyping then return
	elseif Input.KeyCode== Enum.KeyCode.E then
		if not Activated then
			Activated = true
			ShirtChangeEvent:FireServer()
		end
		
	end
	
end)

ShirtChangeEvent.OnClientEvent:Connect(function()
	wait(Cooldown)
	Activated = false
	
end)

This is exactly the same as what I wrote?

No, you had a capitalization error in keycode, so it failed to work.

Oh I saw and fixed that already but it stilll wouldn’t work, perhaps the code is wrong?

No, I tested out my code and it worked perfectly.

You spelt keycode like this Keycode, but it was meant to be spelled like this, KeyCode.

Wow it worked, thanks for your help fam. Appreciate it.

No problem :slight_smile:, hope you have fun developing roblox games!