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

Update TextButton on SurfaceGUI's?

Asked by
Omarstein 100
10 years ago

So I was working on a game, and I had a SurfaceGUI in the StarterGUI and its Adornee was set to the brick. The SurfaceGUI shows the player their money, the money that the player has is stored in an IntValue, and each second the TextButton in the SurfaceGUI would get updated, but it would only get updated in the properties menu, not in-game. Help?

--SCRIPT--

script.Parent.MouseButton1Click:connect(function()
    local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
    script.Parent.Parent.Visible = false    
    if(plr:FindFirstChild("leaderstats").DjBux.Value >= 140)then
        script.Parent.Parent.Parent.Yes.Visible = true
        plr:FindFirstChild("leaderstats").DjBux.Value = plr:FindFirstChild("leaderstats").DjBux.Value - 140
        game.StarterGui.SurfaceGui.Frame.money.Money.Value = game.StarterGui.SurfaceGui.Frame.money.Money.Value + 140
        game.StarterGui.SurfaceGui.Frame.money.Text = "$: "..game.StarterGui.SurfaceGui.Frame.money.Money.Value --This part works perfectly but the effect won't show on the SurfaceGui, but if i go in the properties of the money text button the text is correct...
        script.Parent.Parent.Parent.Yes.Visible = true
    end
end)

1 answer

Log in to vote
0
Answered by 10 years ago

Ok first off you shouldn't be getting the surface gui located in StarterGui, that's the games that clones to each player. What you want to do is locate the SurfaceGui inside the Players Backpack. Your changing the SurfaceGui located in StarterGui so when you reset it updates, however everyone gets that update not only you. So here is my suggestion:

script.Parent.MouseButton1Click:connect(function()
 if(plr:FindFirstChild("leaderstats").DjBux.Value >= 140)then
        script.Parent.Parent.Parent.Yes.Visible = true
        plr:FindFirstChild("leaderstats").DjBux.Value = plr:FindFirstChild("leaderstats").DjBux.Value - 140
       plr.PlayerGui.SurfaceGui.Frame.money.Money.Value = plr.PlayerGui.SurfaceGui.Frame.money.Money.Value + 140
        plr.PlayerGui.SurfaceGui.Frame.money.Text = "$: "..plr.PlayerGui.SurfaceGui.Frame.money.Money.Value
        script.Parent.Parent.Parent.Yes.Visible = true
end
end)

This locates the SurfaceGui inside the Player, which automatically updates it also doesn't allow others to see your stats on their Surface Gui. If I were you I'd go back through and check your frames and GUI make sure the SurfaceGui is located inside the StarterGui in game, so that it clones into the player's PlayerGui. Hope this helped!

0
Posted it :) Omarstein 100 — 10y
0
Did this help? micke3212 35 — 10y
0
Thank you so much! It worked! :D Omarstein 100 — 10y
Ad

Answer this question