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

How to change text in text button(ShopGUI)?

Hello, I have problem with script in text button, which is in Shop GUI. Here is script:

local price = 500
function Buy ()
	local player = script.Parent.Parent.Parent.Parent.Parent
	if player.leaderstats.Points.Value >= price then
		player.leaderstats.Points.Value = player.leaderstats.Points.Value - price
		player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 2
		game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "Purchased!"
		wait(1)
		game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "WalkSpeed +2 ~500 Points~"
	else
		game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "Not Enought Points!"
		wait(1)
		game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "WalkSpeed +2 ~500 Points~"
	end
end

script.Parent.MouseButton1Down:connect(Buy)

So he should show me "Purchased" when player buy "Walkspeed +2" and back to original text "WalkSpeed +2 500 Points, but don't work. Without these lines, works perfectly :

game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "Purchased!"
		wait(1)
		game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "WalkSpeed +2 ~500 Points~"
	else
		game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "Not Enought Points!"
		wait(1)
		game.StarterGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "WalkSpeed +2 ~500 Points~"

So can someone fix it?

3 comments

0

Does anything come out on OutPut?

0

Nope, script just not work with these lines.

0

player.PlayerGui not game.StarterGui

1 answer

✓ Accepted answer

You're error here is you changing the texte of the server and not of your player because you're using game.StarterGui and not player.PlayerGui

The code fix here:

local price = 500
function Buy ()
    local player = script.Parent.Parent.Parent.Parent.Parent
    if player.leaderstats.Points.Value >= price then
        player.leaderstats.Points.Value = player.leaderstats.Points.Value - price
        player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 2
        player.PlayerGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "Purchased!"
        wait(1)
        player.PlayerGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "WalkSpeed +2 ~500 Points~"
    else
        player.PlayerGui.ShopGUI.ShopFrame["WalkSpeed +2"].Text = "Not Enought Points!"
        wait(1)
        player.PlayerGuiShopGUI.ShopFrame["WalkSpeed +2"].Text = "WalkSpeed +2 ~500 Points~"
    end
end

script.Parent.MouseButton1Down:connect(Buy)

2 comments

2

Ugh.. my bad. Thanks for help :)

0

You're welcome !

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