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

Text showing on server but not on client?

Asked by
kepiblop 124
3 years ago
Edited 3 years ago

I cannot show the whole entire script unfortunately but i can however show the typing and getting player img one Okay i know what your thinking "Where are you going with this??" well basically in short, i'm making a camping game and it is working but! It is only showing on the server instead of the client This is a Script not a local script Let me explain What text label in the server says On the server Player: The quick brown fox jumps over the lazy dog And this is the textlabel text on the client Label Here is the pictures Client

Server Okay on with that here's the code!

local function typing(text) --This will make a typing effect
    for i = 1,#text,1 do
        game.StarterGui.ScreenGui.Frame.TextLabel.Text = string.sub(text,1,i)
        local sound = Instance.new("Sound",game.ReplicatedStorage)
        sound.SoundId = "rbxassetid://515150941"
        sound.PlayOnRemove = true
        sound:Destroy()
        wait()
    end
end
--Note that these both are working but the client cannot see them
local function getplayerimg()
    local headshotformat = Enum.ThumbnailType.HeadShot
    local thumb = Enum.ThumbnailSize.Size180x180
    local randomPlayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]
    local Userid = game.Players:GetUserIdFromNameAsync(randomPlayer.Name)
    local picture = game.Players:GetUserThumbnailAsync(Userid,headshotformat,thumb)
    game.StarterGui.ScreenGui.Frame.ImageLabel.Image = picture

This may be because i'm not using a Local script that's because i want others to be able to see the text Any help is appreciated!

0
Please clarify what are you saying. Its confusing! And also clarify what is being seen on server and not on client BestCreativeBoy 1395 — 3y
0
Okay sorry i will get onto that kepiblop 124 — 3y
0
Just clarify the above mentioned things and I might be able to help BestCreativeBoy 1395 — 3y
0
Okay kepiblop 124 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

First thing, in line 3, I noticed:

game.StarterGui.ScreenGui.Frame.TextLabel.Text = string.sub(text,1,i)

Just to clarify, if you want to update player's gui, don't index game.StarterGui as the contents of StarterGui gets copied to PlayerGui which is located in the Player name's folder.

There are two ways you can do this: First, by firing all Clients and then in a LocalScript doing the stuff. For eg:

--Script
-- Instead of what you wrote on line 3, do:
game.ReplicatedStorage.REMOVE_EVENT:FireAllClients(text) -- Change the name of ur RE

--LocalScript inside ur TextLabel (which you mentioned in Line 3)
game.ReplicatedStorage.REMOTE_EVENT.OnClientEvent:Connect(function(text)
    script.Parent.Text = string.sub(text, 1, i)
end)

Another way is that you can loop through all the players and change their TextLabel Text:

-- Instead of what you wrote in line 3
local players = game.Players:GetPlayers()

for i, v in pairs(players) do
    v:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Frame.TextLabel.Text = string.sub(text, 1, i) -- Change the name of ScreenGui to prevent infinite yield (If there are more gui named ScreenGui)
end

I am not entirely sure if Method 2 will work, as I have not tested it in Studio.

Lemme know if it helps!

0
Welp my only option i guess is using a remote event oh boy this is gonna be a pain to go through 69 typing ones thanks anyways! kepiblop 124 — 3y
0
I actually solved it by using script.Parent but your input helped me a bit! Thanks alot! kepiblop 124 — 3y
0
Glad to hear that! BestCreativeBoy 1395 — 3y
Ad

Answer this question