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.
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)
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)