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

How to assign an Image to an ImageLabel on a script?

Asked by 4 years ago

I have tried doing so for several hours, yet it does not work

script.RemoteEvent.OnServerEvent:Connect(function(player)

    local np =  Instance.new("ImageLabel")

    np.AnchorPoint = Vector2.new(0.5, 0.5)
    np.Position = UDim2.new(0.5, 0, 0.5, 0)
    np.Size = UDim2.new(1, 0, 1, 0)
    np.BackgroundTransparency = 1
    np.Parent = game.Workspace:FindFirstChild("1"..player.Name).BillboardGui
    game.Workspace:FindFirstChild("1"..player.Name).BodyPosition.Position = Vector3.new(-451.013, 28.025, 3099.5)
    wait(0.3)
    game.Workspace:FindFirstChild("1"..player.Name).BillboardGui.ImageLabel.Image =
"http://www.roblox.com/asset/?id="..script.Parent.Parent.TextBox.Text


end)

Everything works just fine until the image from the TextBox is assigned, it just does not appear, perhaps the reason is the Text property of a TextBox does not Change when something Is written on it.

0
Any errors? ArtFoundation 255 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
script.RemoteEvent.OnServerEvent:Connect(function(player)

    local np =  Instance.new("ImageLabel")

    np.AnchorPoint = Vector2.new(0.5, 0.5)
    np.Position = UDim2.new(0.5, 0, 0.5, 0)
    np.Size = UDim2.new(1, 0, 1, 0)
    np.BackgroundTransparency = 1
    np.Parent = game.Workspace:FindFirstChild("1"..player.Name).BillboardGui
    game.Workspace:FindFirstChild("1"..player.Name).BodyPosition.Position = Vector3.new(-451.013, 28.025, 3099.5)
    wait(0.3)
    game.Workspace:FindFirstChild("1"..player.Name).BillboardGui.ImageLabel.Image = "rbxassetid://"..script.Parent.Parent.TextBox.Text


end)

The problem here is probably using "http://www.roblox.com/asset/?id=" instead of "rbxassetid://". Hope this helps :)

0
Thanks for the help, I guess it worked, but i just realised it simply fails to load now :3 boyparis 14 — 4y
Ad

Answer this question