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

how do I get this bit of thee script to work properly?

Asked by
KenzaXI 166
9 years ago
local Brick = script.Parent.Parent.Parent
local Picture = script.Parent.UserImage
local User = script.Parent.Username
function onTouch(Object)
    local Character = Object.Parent:FindFirstChild("Humanoid")
    if (Character ~= nil)then
        local Player = 
        game.Players:GetPlayerFromCharacter(Object.Parent)
        if (Player ~= nil)then
            Picture.Image = "http://www.roblox.com/User.aspx?ID="..Player.userId
            User.Text = Player.Name
        end
    end
end
script.Parent.Parent.Parent.Touched:connect(onTouch)

""

if (Player ~= nil)then
            Picture.Image = "http://www.roblox.com/User.aspx?ID="..Player.userId
            User.Text = Player.Name

"" I can't get this bit to work! Please help me, Thanks!

1 answer

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

You need to use the correct format for getting the player's character image. To do this, we'll use:

"http://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&username="..Player.Name

So let's insert this into the script:

local Brick = script.Parent.Parent.Parent
local Picture = script.Parent.UserImage
local User = script.Parent.Username
function onTouch(Object)
    local Character = Object.Parent:FindFirstChild("Humanoid")
    if (Character ~= nil)then
        local Player = 
        game.Players:GetPlayerFromCharacter(Object.Parent)
        if (Player ~= nil)then
            Picture.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&username="..Player.Name
            User.Text = Player.Name
        end
    end
end

script.Parent.Parent.Parent.Touched:connect(onTouch)

Anyways, it should work now, as I did test it. If not, or if you have any further questions/problems, please leave a comment below. Hope I helped :P

0
Well, thanks for no feedback. dyler3 1510 — 9y
0
Took the words right out of my keyboard...that was exactly what I was going to say. lightpower26 399 — 9y
0
My comment or answer on his question? dyler3 1510 — 9y
0
Thanks, Sorry I just viewed this, I was doing Revision for my exams :P thanks dude KenzaXI 166 — 9y
0
Lol, sorry, no problem. DId this work for you, or have you not tested it? dyler3 1510 — 9y
Ad

Answer this question