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

Help With OnSpawn Chracter Mesh?

Asked by
Pyracel 55
9 years ago

I have made a script but I dont know exactly why it wont work.

local player = game.Players.LocalPlayer
local character = player.Character

local RightArm = Instance.new("CharacterMesh") 
RightArm.MeshId = 111777972
RightArm.OverlayTextureId = 256924520

local LeftArm = Instance.new("CharacterMesh")
LeftArm.OverlayTextureId =256924520
LeftArm.MeshId = 111777907

local Torso = Instance.new("CharacterMesh") 
Torso.MeshId = 111777866
Torso.OverlayTextureId = 256924520

local LeftLeg = Instance.new("CharacterMesh") 
LeftLeg.MeshiId = 111777907
LeftLeg.OverlayTextureId = 256924520

local RightLeg = Instance.new("CharacterMesh") 
RightLeg.MeshiId = 111778023
RightLeg.OverlayTextureId = 256924520


if not character or not character.Parent then
    character = player.CharacterAdded:wait()

RightArm:clone()
RightArm.Parent = character

LeftArm:clone()
LeftArm.Parent = character

Torso:clone()
Torso.Parent = character

RightLeg:clone()
RightLeg.Parent = character

LeftLeg:clone()
LeftLeg.Parent = character

end

I clone each mesh so that I will have a second one when the character dies. I would also like to ask how to take away the current character mesh, then add the new one.

1 answer

Log in to vote
0
Answered by
bno23 30
9 years ago

For one, you don't have the BodyPart value set, so it will choose the default, not what you intend it to be.

Also, it seems that you have RightLeg.MeshiId and LeftLeg.MeshiId instead of RightLeg.MeshId and LeftLeg.MeshId.

Nor does the meshes appear to have any parent, because you haven't set them a parent, you can do this in 2 ways, one way is in the Instance.new function, the second argument is optional, but you can set it there. Or you can set the parent manually by setting its parent value.

ex:

-- way 1
part1 = Instance.new("Part", workspace)

-- way 2
part2 = Instance.new("Part")
part2.Parent = workspace

Both ways will work.

And the death detection part shouldn't be there as long as the localscript is replicated every time the player dies. This can be acheived easily by placing the localscript in StarterGui or StarterPlayerScripts

And just to save you some time, here's a fixed up version of your code:

local player = game.Players.LocalPlayer
local character = player.Character


local RightArm = Instance.new("CharacterMesh", character) 
RightArm.BodyPart = "RightArm"
RightArm.MeshId = 111777972
RightArm.OverlayTextureId = 256924520

local LeftArm = Instance.new("CharacterMesh", character)
LeftArm.BodyPart = "LeftArm"
LeftArm.OverlayTextureId =256924520
LeftArm.MeshId = 111777907

local Torso = Instance.new("CharacterMesh", character) 
Torso.BodyPart = "Torso"
Torso.MeshId = 111777866
Torso.OverlayTextureId = 256924520

local LeftLeg = Instance.new("CharacterMesh", character) 
LeftLeg.BodyPart = "LeftLeg"
LeftLeg.MeshId = 111777907
LeftLeg.OverlayTextureId = 256924520

local RightLeg = Instance.new("CharacterMesh", character) 
RightLeg.BodyPart = "RightLeg"
RightLeg.MeshId = 111778023
RightLeg.OverlayTextureId = 256924520
Ad

Answer this question