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

How to change text in text button(ShopGUI)?

Asked by 9 years ago

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?

0
Does anything come out on OutPut? HungryJaffer 1246 — 9y
0
Nope, script just not work with these lines. DevKarolus1 70 — 9y
0
player.PlayerGui not game.StarterGui XToonLinkX123 580 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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
Ugh.. my bad. Thanks for help :) DevKarolus1 70 — 9y
0
You're welcome ! XToonLinkX123 580 — 9y
Ad

Answer this question