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

01script.RemoteEvent.OnServerEvent:Connect(function(player)
02 
03    local np =  Instance.new("ImageLabel")
04 
05    np.AnchorPoint = Vector2.new(0.5, 0.5)
06    np.Position = UDim2.new(0.5, 0, 0.5, 0)
07    np.Size = UDim2.new(1, 0, 1, 0)
08    np.BackgroundTransparency = 1
09    np.Parent = game.Workspace:FindFirstChild("1"..player.Name).BillboardGui
10    game.Workspace:FindFirstChild("1"..player.Name).BodyPosition.Position = Vector3.new(-451.013, 28.025, 3099.5)
11    wait(0.3)
12    game.Workspace:FindFirstChild("1"..player.Name).BillboardGui.ImageLabel.Image =
13"http://www.roblox.com/asset/?id="..script.Parent.Parent.TextBox.Text
14 
15 
16end)

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
01script.RemoteEvent.OnServerEvent:Connect(function(player)
02 
03    local np =  Instance.new("ImageLabel")
04 
05    np.AnchorPoint = Vector2.new(0.5, 0.5)
06    np.Position = UDim2.new(0.5, 0, 0.5, 0)
07    np.Size = UDim2.new(1, 0, 1, 0)
08    np.BackgroundTransparency = 1
09    np.Parent = game.Workspace:FindFirstChild("1"..player.Name).BillboardGui
10    game.Workspace:FindFirstChild("1"..player.Name).BodyPosition.Position = Vector3.new(-451.013, 28.025, 3099.5)
11    wait(0.3)
12    game.Workspace:FindFirstChild("1"..player.Name).BillboardGui.ImageLabel.Image = "rbxassetid://"..script.Parent.Parent.TextBox.Text
13 
14 
15end)

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