Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make palyers able to change a number in a script in-game?

Asked by
Exarpo -3
5 years ago

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...

0
does the player write the number in a textbox? CjayPlyz 643 — 5y

1 answer

Log in to vote
0
Answered by
CjayPlyz 643 Moderation Voter
5 years ago
Edited 5 years ago

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)
0
What am I supposed to click to run this after writing the ID of the product? Exarpo -3 — 5y
0
Should this script be in a part that have a click detector in it? Exarpo -3 — 5y
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? Exarpo -3 — 5y
0
Please wait while i make and upload a picture to make things more clearer, after that ill edit my answer. CjayPlyz 643 — 5y
View all comments (9 more)
0
Ok, thx Exarpo -3 — 5y
0
Edit is done, please look. CjayPlyz 643 — 5y
0
Is done CjayPlyz 643 — 5y
0
I did everything it says but its still not working... pls help Exarpo -3 — 5y
0
wait CjayPlyz 643 — 5y
0
Go to roblox and go to a game, ill join u and we can chat, then you can explain Exarpo -3 — 5y
0
It worked fine for me, maybe there's something wrong with your productid please wait while i check my scripts CjayPlyz 643 — 5y
0
No need CjayPlyz 643 — 5y
0
Ok i found an error, ill edit the question please wait CjayPlyz 643 — 5y
Ad

Answer this question