AshRPG12Join Date: 2013-08-30 Post Count: 238 |
I've been using this technique and I want to know why it doesn't work:
variable = game.Players.LocalPlayer (Yes, I'm using a LOCALSCRIPT)
variable:waitForChild("Character") -- is this a workable function?
-- I found out that roblox updated so that you can't directly get the character because it has to load
also how do you find a random player from game.players, get his character, and access his character without any nil value errors. no i dont ask for scripts I ask for the TERMS to use because roblox updates and i cant understand dipppp
|
|
|
i like to use this:
repeat wait() until character~=nil
#Code print("Narwhals are our future") |
|
ez_streetJoin Date: 2013-07-11 Post Count: 364 |
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character |
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
That's weird I never heard of repeated code that waits until character is nil, well maybe if I had some bright ideas on some easy things I'd knew that already.
|
|
|
You cant use WaitForChild() because 'Character' is not a child, it is a property of Player
Instance.new("BodyThrust",SenseiWarrior).position = CFrame.new(SenseiWarrior,YourGirlsDMs) |
|
|
That waits until its not nil actually.
And the best way to wait for the character is
local character = (player.Character or player.characterAdded:wait())
You can not waitForChild("Character") because player.Character is a property. |
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
but can I get to know the terms to get a player's character in math.random terms by randomly selecting a player?
repeat wait() until game.Players.NumPlayers > 0
local players = game.Players
local mathrandom = math.random(1, #players)
local playerchosen = players[mathrandom]
repeat wait() until playerchosen.Character~=nil
playerchosen.Character.Torso.Transparency = 0.5
playerchosen.Character.Head.Transparency = 1
-- crashed when testing this wtf
|
|
4efJoin Date: 2013-05-27 Post Count: 5683 |
:GetPlayerByCharacter()
|
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
player.Character is not loaded instantly due to the new roblox studio updates so ye but ill see about it I just watch a lot of tutorials, use the wiki, but I can't find places where it is explained easily or well or videos that are recently updated to find these matters.
|
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
@4ef
player's character, not player from character
|
|
4efJoin Date: 2013-05-27 Post Count: 5683 |
:GetPlayerFromCharacter()
mb
|
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
:GetPlayerFromCharacter
gets the player from the character
my question is to get the character, not from.
xloadinq 2fat4u |
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
repeat wait() until game.Players.NumPlayers > 0
local players = game.Players:GetPlayers()
local ranPlayer = players[math.random(1, #players)]
local char = ranPlayer.Character
char.Torso.Transparency = 0.5
char.Head.Transparency = 1 |
|
AshRPG12Join Date: 2013-08-30 Post Count: 238 |
i've asked to for the topics to get a player's character not randomly select a player and way long after this forum post i already knew almost everything about players but its okay and heres the corrected script, repeating would just make more lag and is unnecessary:
game.Players.Changed:connect(function()
if game.Players.NumPlayers > 0 then
local players = game.Players:GetPlayers()
local ranPlayer = players[math.random(1, #players)]
local char = ranPlayer.Character
-- char invisibility
char.Torso.Transparency = 0.5
char.Head.Transparency = 1
-- etc put here:
end
end)
xloadinq 2fat4u |
|