Don't try to access Server Storage via LocalScript as it will not work. Bcz Server Storage is accessable by server only.
This is not going to be a simple thing..
First, Local script in TextButton.
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.YOUR_REMOTE_EVENT_NAME:FireServer()
end
Then, the Server script in ServerScriptService.
local function applyBodyColors(player, item, RigType)
local char = player.Character
item.Parent = char
end
local function applyBodyPart(player, item, RigType)
if RigType == "R15" then
local replace = player.Character:FindFirstChild(item.Name)
if replace then
item.Parent = player.Character
replace:Destroy()
end
player.Character.Humanoid:BuildRigFromAttachments()
else
for _, oldPart in ipairs(player.Character:GetChildren()) do
if oldPart.ClassName == "CharacterMesh" then
if oldPart.Name == item.BodyPart.Name then
oldPart:Destroy()
end
end
end
item.Name = item.BodyPart.Name
item.Parent = player.Character
end
end
local function AddItemToCharacter(player, item, rigType)
local Type = item.ClassName
if Type == "Accessory" or Type == "Shirt" or Type == "Pants" or Type == "Hats" then
item.Parent = player.Character
elseif Type == "Tool" then
item.Parent = player.Backpack
elseif item.Name == "Head" then
player.Character.Head.Mesh:Destroy()
item.Mesh.Parent = player.Character.Head
player.Character.Head.face:Destroy()
item.face.Parent = player.Character.Head
player.Character.Head.Color = item.Color
elseif Type == "MeshPart" then
applyBodyPart(player, item, rigType)
elseif Type == "BodyColors" then
applyBodyColors(player, item, rigType)
end
end
local function loadCharacter(player)
local Character = player.Character or player.CharacterAdded:Wait()
local RigType = Character.Humanoid.RigType == Enum.HumanoidRigType.R15 and "R15" or "R6"
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local NewCharacter = ReplicatedStorage:WaitForChild("Character")
if NewCharacter then
if player:HasAppearanceLoaded() == false then
repeat until player:HasAppearanceLoaded() == true
end
player:ClearCharacterAppearance()
local EquipCharacter = NewCharacter:Clone()
for _, item in pairs(EquipCharacter:GetChildren()) do
AddItemToCharacter(player, item, RigType)
end
end
end
game.ReplicatedStorage.YOUR_REMOTE_EVENT_NAME.OnServerEvent:Connect(loadCharacter)
It's too long I know and just don't copy/paste. Try to understand the script first.
Make sure to add Remote Event in ReplicatedStorage and rename it to that you will be using in the script.
Also, add the character u want to give the player in ReplicatedStorage.
Lemme know if it helps! Please do give an Upvote if it helped you bcz the script took really long time to write.
2 comments
imma give you an update wether it worked or not cause gosh darn thats a long script
UPVOTE*