Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Changing CharacterAppearance working in-studio, not in-game?

Asked by 5 years ago
Edited 5 years ago

So, I was playing around with changing a player's appearance via CharacterAppearance and I've stumbled upon an issue. It works perfectly fine in studio, but it doesn't want to work in-game. Tried multiple different things, but nothing seems to work. It's been FE'd, so I honestly don't know what the issue is. Here's what I've got:

Server Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeEvent = ReplicatedStorage:WaitForChild("ChangeEvent")
local Players = game:GetService("Players")

local function changed(plr)
    plr.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=1"
    local Pos = plr.Character:GetPrimaryPartCFrame()
    plr:LoadCharacter()
    plr.Character:SetPrimaryPartCFrame(Pos)
    print("Changed")
end


ChangeEvent.OnServerEvent:Connect(changed)

Local Script:

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("ChangeEvent")


local function change(inputObject, gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.E then
        Event:FireServer()
        print("Key Pressed")
    end
end

UserInputService.InputBegan:Connect(change)

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

So, the "CharacterAppearance" property is deprecated. Try using "CharacterAppearanceId" instead. Not only is it easier, but it may solve your issue. I've fixed up the server script with CharacterAppearanceId, and I've also compiled your functions in both of the scripts by connecting it with the argument which I personally find a little more efficient than having all the connections at the bottom of the script. Lastly, in the sever script you had a "Players" variable that was not needed by anything within the script, so I just removed that as well.

Server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeEvent = ReplicatedStorage:WaitForChild("ChangeEvent")

ChangeEvent.OnServerEvent:Connect(function(plr))
    plr.CharacterAppearanceId = 1 -- The number 1 is the user ID
    local Pos = plr.Character:GetPrimaryPartCFrame()
    plr:LoadCharacter()
    plr.Character:SetPrimaryPartCFrame(Pos)
    print("Changed")
end

Local script:

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("ChangeEvent")

UserInputService.InputBegan:Connect(function(inputObject, gameProcessed))
    if inputObject.KeyCode == Enum.KeyCode.E then
        Event:FireServer()
        print("Key Pressed")
    end
end
0
Thanks a bunch, your fix worked like a charm. It functions as it should now. HackerZone123 2 — 5y
0
No problem, if you want you can go ahead and accept my answer then the thread will be closed to responses, good luck! EliteJcoombs 77 — 5y
Ad

Answer this question