Roblox Central

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Roblox Central

Discussion for all things Roblox. (roblox.com)

Welcome to the new forum! Any suggestions you have are greatly appreciated.
WARNING: Before referring anyone to this website, Please read this topic

4 posters

    My problem with character

    iMathRandom
    iMathRandom
    Mod


    Posts : 66
    Join date : 2009-06-21
    Location : Ohio

    My problem with character Empty My problem with character

    Post by iMathRandom Sun Jun 21, 2009 11:24 pm

    When ever I use player.character, it doesn't work.

    Ex:
    Code:
    function new(newPlayer)
    newPlayer.Character.Humanoid.MaxHealth = 50
    newPlayer.Character.Humanoid.Health = 50
    end
    game.Players.ChildAdded:connect(new)
    -- this would break
    avatar
    Jfeather
    Admin


    Posts : 232
    Join date : 2009-06-18
    Location : This Forum. Duh.

    My problem with character Empty Re: My problem with character

    Post by Jfeather Mon Jun 22, 2009 5:13 am

    This is just an educated guess, but you're trying to edit a 'Character' in the 'Players' folder. A player's Character is located in the Workspace, not Players.
    Earth
    Earth
    Admin


    Posts : 402
    Join date : 2009-06-18
    Location : According to my IP address: Topeka, Kansas.

    My problem with character Empty Re: My problem with character

    Post by Earth Mon Jun 22, 2009 8:01 am

    Code:

    function new(newChar)
    if newChar ~= "Character" then return end
    newChar.Humanoid.MaxHealth = 50
    newChar.Humanoid.Health = 50
    end
    function newPlayer(p)
    while p.Character == nil do wait(1) end
    p.Changed:connect(new)
    end
    game.Players.ChildAdded:connect(newPlayer)

    Try that typed in reply box may not work.
    Meelo
    Meelo
    Admin


    Posts : 217
    Join date : 2009-06-19

    My problem with character Empty Re: My problem with character

    Post by Meelo Mon Jun 22, 2009 12:10 pm

    There's some mistakes in your code - it wouldn't trigger when the player spawned for the first time, "newChar" is a string, and you're using it as an object "newChar.Humanoid" isn't valid.

    Code:
    function newPlayer(p)
    p.Changed:connect(function(n)
    if(n == "Character")then
    if(p.Character)then
    p.Character.Humanoid.Health = 50
    p.Character.Humanoid.MaxHealth = 50
    end
    end
    end)
    end
    game.Players.ChildAdded:connect(newPlayer)
    iMathRandom
    iMathRandom
    Mod


    Posts : 66
    Join date : 2009-06-21
    Location : Ohio

    My problem with character Empty Re: My problem with character

    Post by iMathRandom Mon Jun 22, 2009 1:29 pm

    Is there an easier way to do it, like a GetCharacterFromPlayer function, lolz.
    Earth
    Earth
    Admin


    Posts : 402
    Join date : 2009-06-18
    Location : According to my IP address: Topeka, Kansas.

    My problem with character Empty Re: My problem with character

    Post by Earth Mon Jun 22, 2009 3:10 pm

    Oh whatever I told you I typed it in the reply box pretty fast Razz
    Meelo
    Meelo
    Admin


    Posts : 217
    Join date : 2009-06-19

    My problem with character Empty Re: My problem with character

    Post by Meelo Mon Jun 22, 2009 4:40 pm

    So did I. I just didn't... include a... disclaimer... Whoops...

    Sponsored content


    My problem with character Empty Re: My problem with character

    Post by Sponsored content

      Similar topics

      -

      Current date/time is Mon May 20, 2024 4:31 am