Ok,so I decided to make a script of mine into a local script and it seems to act odd. It fails at making the welds and destroying the left arm at death in solo.Every time I start a sever with 2 players it get an error saying:
Players.Player1.PlayerGui.LocalScript:10: attempt to index global 'Character' (a nil value)
which I don't get because I have a variable called Character at line 2.Oh,and this seems to work find when I put it in a regular script,why and how do I fix all these problems?
LocalScript:
Player = game.Players.LocalPlayer
local Character = Player.Character
if not Character or Character.Parent == nil
then Character = Player.CharacterAdded:wait()
---------------------------------------------------------
Player.CameraMode= Enum.CameraMode.LockFirstPerson
---------------------------------------------------------
function MakeDisplayArms()
---------------------------------------------------------
local CurrentCamera = game.Workspace.CurrentCamera
local PlayerArms = {
Character:WaitForChild("Right Arm"),
Character:WaitForChild("Left Arm")}
local ClonedArms = {}
---------------------------------------------------------
for i,v in pairs (PlayerArms) do
wait()
local Clone = v:Clone()
Clone.Name = "Cloned_"..v.Name --Renames it
Clone.CanCollide = true
local Weld = Instance.new("Weld",Clone)
Weld.Part0 = Clone
Weld.Part1 = v
Clone.Parent = CurrentCamera--Hides it from everyone else
ClonedArms[i] = Clone
end
Character.Humanoid.Died:connect(function()
wait()
for Index,Parts in pairs (ClonedArms)do
print(Parts.Name)
Parts:Destroy()
table.remove(ClonedArms,Index)
Parts:BreakJoints()
end
end)
end
return ClonedArms
end
---------------------------------------------------------
MakeDisplayArms()
If you want to test it in place it's here.
It's so hard working with local scripts. qq

20 comments
Sorry to bother you, but it only solved some of it.The welds aren't working still,is there anyway I can fix it?I also got a new error (I also updated the script) Right Arm is not a valid member of Model
It's possible that the Right Arm hasn't been created yet. On line 10 and 11, if the arms don't exist, it will throw an error because you're trying to index them.
I recommend changing lines 10 and 11 to use WaitForChild too. e.g. Character:WaitForChild("Right Arm")
I changed it and works it just won't remove on death and then the arms won't spawn until I reset again then the arms come out when I reset but then won't get destroyed.
Is there any output? Press F9 and click on Local Console. Look for red errors.
think because it won't wait for the character,but how would I make it do that if it's in the loop already?
No errors in studio while starting a server nor in Online
On line 26, try adding: print(Parts.Name) Parts:Destroy()
It printed "Cloned_Right Arm" at the first time I reseted,then It didn't print at all at the second reset(I updated script again).
Looks like the arms are falling to the ground. Don't parent them to CurrentCamera until after the weld is created.
It fixed the problem in solo but it still doesn't work in a server and I parented it in line 22
I think the problem may be that when the Localscript first runs, Player.Character still points to the old character model.
Try changing line 2 to this: local Character = Player.Character if not Character or Character.Parent == nil then Character = Player.CharacterAdded:wait() end
It didn't do anything and what do you mean that is still points to the old model,the Character changes when a player enters?
After your character dies, local scripts may run before the new character respawns. In that case it would be cloning the old limbs.
Probably if I edit something within the Died event it fix it.I'll add a wait.
That didn't work,maybe if I try to compare the Character when he spawns with the character after?I have to go for now,bye and thanks for the help for today.
It won't lock the player in first person mode but it will change the property.I tried using "WaitForChild("Camera") but it didn't work,why?
So the arms part of the script works, just not the camera?
yes