So I came back to scripting and got some progress on some game. I'm trying to change text in a GUI to correspond with a value and it works in properties, but the text doesn't show on the GUI.
CODE:
01 | local earned = false |
02 | script.Parent.Touched:Connect( function () |
03 | if earned = = false then |
04 | game.StarterGui.PointGUI.Value.Value = game.StarterGui.PointGUI.Value.Value + 1 |
05 | game.StarterGui.PointGUI.TextLabel.Text = "Point Count: " .. game.StarterGui.PointGUI.Value.Value |
06 | print ( "1" ) |
07 | earned = true |
08 | else |
09 | print ( "Already gained" ) |
10 | end |
11 | end ) |
You are changing the property for the gui in the startergui, not the playergui. If a new player were to join, they would see the correct text, but it would not change. I would try
01 | local earned = false |
02 | script.Parent.Touched:Connect( function (hit) |
03 | if hit.Parent.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
04 | local plr = game.Players:FindFirstChild(hit.Parent.Name) |
05 | if earned = = false then |
06 | plr.PlayerGui.PointGUI.Value.Value = plr.PlayerGui.PointGUI.Value.Value + 1 |
07 | plr.PlayerGui.PointGUI.TextLabel.Text = "Point Count: " .. plr.PlayerGui.PointGUI.Value.Value |
08 | print ( "1" ) |
09 | earned = true |
10 | else |
11 | print ( "Already gained" ) |
12 | end |
13 | end |
14 | end ) |
Well as coratite said You are changing the property for the gui in the startergui, not the playergui. but go to part that you want to touch the player to earn points then insert script(serverside). Type this lines.
01 | -- Identifying variables |
02 | local earned = false |
03 | function touch(hit) |
04 | if game.Players:FndFirstChild(hit.Parent.Name) ~ = nil then |
05 | player = game.Players [ hit.Parent.Name ] |
06 | if not earned then -- you can use this but you can change the not earned to earned == false |
07 | earned = true |
08 | player.PlayerGui.PointGUI.Value.Value = player.PlayerGui.PointGUI.Value.Value + 1 |
09 | player.PlayerGui.PointGUI.TextLabel.Text = "Point Count: " ..player.PlayerGui.PointGUI.Value.Value |
10 | print ( 1 ) |
11 | earned = false |
12 | else |
13 | print ( "Already Gained" ) |
14 | end |
15 | end |
16 | end |
that it .Sorry for indentions and grammers but try it.