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

screen gui doesnt change billboard text. WHY???

Asked by 6 years ago
local BillboardGui = game:GetService('ReplicatedStorage'):WaitForChild('BillboardGui')
local text = script.Parent.Parent.TextBox.Text
script.Parent.MouseButton1Click:connect(function()
    BillboardGui.frame.TextBox.Text = text
    print ("text changed")
end)
local BillboardGui = game:GetService('ReplicatedStorage'):WaitForChild('BillboardGui') --You may have also made a spelling mistake here.

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char) --Fires everytime the player respawns
        char:WaitForChild('Head')
        local clonedBillBoard = BillboardGui:Clone()
        clonedBillBoard.Parent = char.Head
        clonedBillBoard.frame.RPText.Text = plr.Name
    end)
end)

the first script is in a textutton and the second is in server script service

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago

You're changing the UI stored in ReplicatedStorage, rather than the one in the client's PlayerGui.

Parent the Billboard to the client's PlayerGui, and set its Adornee property to the client's Head.

TextButton LocalScript:

local plr = game.Players.LocalPlayer --The client
local plrUI = plr:WaitForChild("PlayerGui") --The client's UI
local BillboardGui = plr:WaitForChild("BillboardGui") --Billboard

script.Parent.MouseButton1Click:connect(function()
    --Define inside the event so 'text' variable updates
    local text = script.Parent.Parent.TextBox.Text
    BillboardGui.frame.TextBox.Text = text
    print("text changed")
end)

Script in ServerScriptService:

--No need for WaitForChild since it is in ReplicatedStorage
local BillboardGui = game.ReplicatedStorage.BillboardGui

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:WaitForChild("Head")
        local clonedBillBoard = BillboardGui:Clone()
        --Parent(where its located)
        clonedBillBoard.Parent = plr.PlayerGui
        --Adornee(where it shows up)
        clonedBillBoard.Adornee = char.Head
        clonedBillBoard.frame.RPText.Text = plr.Name
    end)
end)
0
i get this error 19:39:08.069 - Infinite yield possible on 'Players.EpicAshtonTheBoy:WaitForChild("BillboardGui")' EpicAshtonTheBoy 33 — 6y
Ad

Answer this question