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

How do i change a StringValue Via a script?

I want to make a simple advertising system, but my problem is that i cant figure out how to change a StringValue's value on a script, I made a gui with a textbutton and a textbox and people will enter the decal id they want to advertise in the textbox and when they click the textbutton the script will add a comma and a space and then the decal id, i am new to scripting, Thank you, Here is my script (for the textbutton)

bought = true
local stringvalue = game.Workspace.VurionaLoader.IDSHERE.Value
local decal = script.Parent.Parent.TextBox.Text

script.Parent.MouseButton1Click:connect(function()
	if bought == true then
		--I dont know what to do here
	end
end)

2 answers

✓ Accepted answer

###Simply assign the value.

local bought = false
local stringvalue = game.Workspace.VurionaLoader.IDSHERE -- Don’t add the .Value
local decal = script.Parent.Parent.TextBox -- Don’t add the .Text

script.Parent.MouseButton1Click:Connect(function()
    stringvalue.Value = "This is my value"
end)

#That’s how you assign values to a StringValue.

1 comment

0

I dont want to remove the data that is already there

If you do not want to delete the current value, you can join the two values

local bought = false
local stringvalue = game.Workspace.VurionaLoader.IDSHERE -- Don’t add the .Value
local decal = script.Parent.Parent.TextBox -- Don’t add the .Text
 
script.Parent.MouseButton1Click:Connect(function()
    stringvalue.Value = decal.Text..IDSHERE.Value
end)

Hope this is what your looking for!

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