Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is wrong with my script?

local c = game.Players:GetChildren() 
local r = math.random(1,game.Players.NumPlayers) 
RANDOMPERSON = nil 
for i = 1,#c do 
if i == r then 
RANDOMPERSON = c[i]
sword = game.Lighting.Sword5:Clone()
sword.Parent = RANDOMPERSON.StarterGear
RANDOMPERSON.Torso.CFrame = CFrame.new(game.Workspace.Juggernaut.Position)
end
end

I got an error saying

Torso is not a valid member of Player

2 answers

Torso is a child of Characters not Players, Characters are found in the Workspace while Players are found in the Players child of game.

2 comments

0

So, what would I do?

0

RANDOMPERSON.Character.Torso

like Perci Commented RandomPerson.Character.Torso also, don't change the Torso Position! change the Character Position! Character:MoveTo() is the correct way to do it! cos the Torso is the connection part for all ur BodyParts and if it changes Position, that means ur Joints Break, and so, Die... so do it my Way!

2 comments

1

I never knew that. You can access a players character in the Workspace from the Player in Players? Did I understand that wrong?

0

if u do for example char = game.Workspace.Guy --This is the Model of the Players Character... so if ya wanted to find the Guy's Player, char:GetPlayerFromCharacter()

This discussion is preserved as it was. New answers, comments, and votes are closed.