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?
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)