Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

Any errors?

1 answer

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 :)

1 comment

0

Thanks for the help, I guess it worked, but i just realised it simply fails to load now :3

This discussion is preserved as it was. New answers, comments, and votes are closed.