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 make palyers able to change a number in a script in-game?

I want to make players able to change a script in-game via an GUI. When they write an number (an ID of a product) in the GUI and press enter, I want to make that the "ID OF THE PRODUCT" get replaced with the number the player writes in the GUI.

THE SCRIPT: local assetid = "ID OF THE PRODUCT"

local cd = script.Parent.ClickDetector

cd.MouseClick:connect(function(player)

game:GetService("MarketplaceService"):PromptPurchase(player,assetid)

end)


Please help...

1 comment

0

does the player write the number in a textbox?

1 answer

✓ Accepted answer

A localscript inside the textbutton

local MarketplaceService = game:GetService("MarketplaceService")

local function onMouseClick (Player)
	local AssetId = tonumber(Player.PlayerGui.ScreenGui.AssetId.Text)
	MarketplaceService:PromptProductPurchase(Player, AssetId)
end

script.Parent.ClickDetector.MouseClick:Connect(onMouseClick)

A server script inside the serverscriptservice

local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

local function OnServerEvent (Player, AssetId)
	Player.PlayerGui.ScreenGui.AssetId.Text = AssetId
	print(Player.PlayerGui.ScreenGui.AssetId.Text)
end

RemoteEvent.OnServerEvent:Connect(OnServerEvent)

A localscript inside the textbox

local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

local function InputEnded ()
	RemoteEvent:FireServer(script.Parent.Text)
end

script.Parent.InputEnded:Connect(InputEnded)

13 comments

0

What am I supposed to click to run this after writing the ID of the product?

0

Should this script be in a part that have a click detector in it?

0

It seams logical but its not working... im quite sure that im doing something wrong, can you please explain where I should put this script?

0

Please wait while i make and upload a picture to make things more clearer, after that ill edit my answer.

0

Ok, thx

0

Edit is done, please look.

0

Is done

0

I did everything it says but its still not working... pls help

0

wait

0

Go to roblox and go to a game, ill join u and we can chat, then you can explain

0

It worked fine for me, maybe there's something wrong with your productid please wait while i check my scripts

0

No need

0

Ok i found an error, ill edit the question please wait

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