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

Quotes and variables not mixing?

Hello and thank you to everyone reading this. I am trying to make it where the decal texture changes to the players profile picture. The problem is since you have to put links in quotes when i change the numbers to the variable everything breaks. If anyone's confused why i'm not just putting the numbers and doing the variable things its because im trying to get this part of it working first and then i will change it to a players id thats in the game at the time.

here's the code

i = 144238599

game.Workspace.ok.Decal.Texture = "https://www.roblox.com/bust-thumbnail/image?userId="(i)"&width=420&height=420&format=png"

Hope someone can tell me why this is not working or a alternative way to do it that works thanks again for reading this.

5 comments

0

You're actually creating two different strings that when combined make up the link. Use " .. i .. " to concatenate i into the string.

0

I'll explain what he means in an answer and give you an easier way to handle this whole thing.

0

did the .. thing and it's working

0

thanks and i'll tag it as a answer if you show me a easier way and explain itt SteamG0D

0

Added an explanation of the whole thing below the code, and an explanation of the function in the comment beside it.

1 answer

✓ Accepted answer
function setDecal(playerID,decal)
	decal.Texture = 'https://www.roblox.com/bust-thumbnail/image?userId=' .. playerID .. '&width=420&height=420&format=png'
end
setDecal(144238599, workspace.ok.Decal) -- this is how you call the function, the parentheses contain the function's arguments (a function can have any number of arguments and they can be any type of variable, and even sometimes functions too) however in this case, it will just be the player's ID number, and the path to the decal.

This allows you to set the texture of any decal to any player's thumbnail. The two dots allow what is called concatenation, all that is is a fancy word for putting two strings (in this case) together. If you google this, most languages just use a + symbol, but lua uses the two dots, so make sure that when concatenating two strings together that you always remember to use the dots instead of the plus.

Since you requested an easier way, all you would have to do is what you did before:

local i = 144238599 --you should always try to use local when setting variables
workspace.ok.Decal.Texture = 'https://www.roblox.com/bust-thumbnail/image?userId=' .. i .. '&width=420&height=420&format=png'

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