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

Can't change the Character property [CAN'T ANIMATE IN SERVER]

Asked by 10 years ago

http://www.roblox.com/B-place?id=127791097

For my game, I have the player automatically morph into another model when they spawn. The problem is, the character will keep respawning if I change it. It works perfectly fine in solo mode, but as soon as I'm in a server it will no longer work.

Additional information: When in the server (when it doesn't work), the animation script for the character won't work either.

EDIT: I found a solution by changing the parent of the cloned model only AFTER I set it as the player's character. So it'd be...

local mc = model:clone()
--blah blah
player.Character = mc
mc.Parent = workspace
--blah blah

But now I have another problem. My animation script uses the old version that Roblox used to use, in which it changes the DesiredAngle of the Motors. Problem is, since I also use the Animation object to do attacks, I need a HumanoidRootPart. Adding that to the model, the animation script no longer works (it's changing the Motor's DesiredAngle and CurrentAngle, but it's not doing anything). This also applies for any of the enemies that I create in the server. And like before, this is only a problem when I'm in a server. Test>Play Solo works fine.

ORIGINAL SCRIPT

--Simplified version of what the script is doing.

function PlayerAdded(player)
    player.CharacterAdded:connect(function(character)
        if character:findFirstChild("FinishedCharacter") then
            return
        end
        wait(0.01)
        local char = player.Character
        local mc = model:clone()
        mc.Name = char.Name
        mc:MakeJoints()
        mc.Parent = workspace
        mc.Humanoid.Health = mc.Humanoid.MaxHealth
        mc:MoveTo(char.Torso.Position)
        Instance.new("ObjectValue",mc).Name = "FinishedCharacter"
        player.Character:Destroy()
        player.Character = mc
        char = player.Character
    end)
end

1 answer

Log in to vote
3
Answered by 10 years ago

The Archivable property must be set to true in order for you to be able to use the Clone method on the object. Character models have this property set to false by default when they spawn.

You need to set this property to true before you can use the Clone method.

--- line 9
local char = player.Character
char.Archivable = true
local mc = model:clone()
-- line 11
0
Nice answer. ConnorVIII 448 — 10y
0
Doesn't make a difference. I'm using Destroy() on the default character model, and cloning an entirely different model stored in ReplicatedStorage. That cloned model will then become the new character for the player. RobustPhysics 25 — 10y
Ad

Answer this question