Need help with inserting a LocalScript for a plugin

Hey everyone, my LocalScript for one of my latest plugins is basically all ready to go except for one line it keeps failing on [which is the donatescript.Source line in the code]. I’ve attached the most important parts of the script below [I’ve cut out most of it as the rest of the code is functioning fine and anyways I don’t want people actually copying the script] and what happens in the Output.

Script
function click()
local DevProduct = script.Parent.Parent.TextBox
local donatescript = Instance.new("LocalScript")
donatescript.Source = "local id = " DevProduct.Text "\nscript.Parent.TextButton.MouseButton1Click:connect(function() \ngame.MarketplaceService:PromptProductPurchase(script.Parent.Parent.Parent.Parent, id) \nend)"
donatescript.Parent = donatebutton
end

script.Parent.MouseButton1Click:Connect(click)
Output

To help people try and help me solve this: Script:16 = donatescript.Source line in the Script

22:35:31.138 - user_Roblox Fast Donation Button Add [Beta, just messing].rbxmx.Roblox Fast Donation Button Add [Beta, just messing].GUI.TextButton.Script:16: attempt to call a string value

22:35:31.139 - Stack Begin

22:35:31.140 - Script ‘user_Roblox Fast Donation Button Add [Beta, just messing].rbxmx.Roblox Fast Donation Button Add [Beta, just messing].GUI.TextButton.Script’, Line 16 - function click

22:35:31.141 - Stack End

Thanks for reading and hopefully we’ll be able to solve this issue :smiley:

I’m confused, is it suppose to be multi line?

The line that has the source in the script is meant to be multi line but I did some research and apparently ‘\n’ works.

Try to see if this works. I’ve noticed that you have added quotations for the same line and should use concatenation. Which will merge your string values together into one.

donatescript.Source = “local id = “… DevProduct.Text …”\nscript.Parent.TextButton.MouseButton1Click:connect(function() \ngame.MarketplaceService:PromptProductPurchase(script.Parent.Parent.Parent.Parent, id) \nend)”

1 Like

I don’t think you wanna use “\n” for this. (also use :Connect, not :connect)

For multi line strings, use: [[

Example:

local k = [[Hello
world!]]
print(k) -- would print multi line "Hello world!"

Worked for me when making .Source scripts via plugins & cmd bar.

I believe :connect still works for compatibility so shouldn’t make any difference.

1 Like

It does work, it is just deprecated.

1 Like

I don’t think that works.

Use two dots instead of three.

It isn’t showing the red line anymore so I’m going to test it now.

Thank you, it finally works.

image

image

1 Like

Great! Consider making my post as marked solution so that others will know its resolved. Glad I could assist.

2 Likes