So, I am basically trying to allow the user with a GUI, add a decal onto a brick, let me clarify that: the decal is already on the brick, and the only issue is translating the variable to a string.
The code is below:
Text = script.Parent.TextBox.Text assetid = toString(Text) script.Parent.TextButton.MouseButton1Click:connect(function (onClick) game.Workspace.Screen.Decal.Texture = ("http://www.roblox.com/asset/?id=%s"):format(assetid) end)
After running this in-game, an error showed up. Here's the image of the error: http:///prntscr.com/amxv49
Would be great if someone could help me out, thanks.
The problem may be that you're initialising the variable 'Text' when the script begins -- not when it's clicked. So, it will be what it was initially, and won't change.
You can fix this by putting it inside of the function:
script.Parent.TextButton.MouseButton1Click:connect(function() Text = script.Parent.TextBox.Text assetid = tostring(Text) game.Workspace.Screen.Decal.Texture = ("http://www.roblox.com/asset/?id=" .. assetid) end)
Hope this helped.
Use:
tostring(Text)
Instead of
toString(Text)
That should fix your issue :)