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

Cant set the text on local script?

Asked by 3 years ago

Ok so i cant change a text in the script but theres no error. Heres the script:

local BES = game.StarterGui.ShopGui.BESystem.ClickBE
local Camera = game.Workspace.CurrentCamera
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    game.StarterGui.ShopGui.BESystem.CostLabel.Text = "Cost:5"
    Camera.CFrame = game.Workspace.ShpCams.Cam1.CFrame
    if plr.Tier.Value >= 1 then
        BES.Buy1.Disabled = true
        BES.Equip1.Disabled = false
        BES.Text = "Equip"
    else
        BES.Text = "Buy"
        BES.Buy1.Disabled = false
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Hello! I believe I see the error.

When a player joins, all GUIs in StarterGui get copied over to each players PlayerGui. This means you need to edit the PlayerGui instead. Try changing this! :)

local plr = game.Players.LocalPlayer
local BES = plr.PlayerGui.ShopGui.BESystem.ClickBE
script.Parent.MouseButton1Click:Connect(function()
    plr.PlayerGui.ShopGui.BESystem.CostLabel.Text = "Cost: 5"

If this doesn't work, let me know and I will try to solve it again.

0
Thx JasiuJasiuB 13 — 3y
1
I also suggest adding WaitForChild("PlayerGui") line so that the script won't error. MysteriousCeburek 27 — 3y
0
Oh, yes. That is a very good suggestion! Amanda314159 291 — 3y
0
Double Thx JasiuJasiuB 13 — 3y
Ad

Answer this question