Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Text showing on server but not on client?

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!

4 comments

0

Please clarify what are you saying. Its confusing! And also clarify what is being seen on server and not on client

0

Okay sorry i will get onto that

0

Just clarify the above mentioned things and I might be able to help

0

Okay

1 answer

✓ Accepted answer

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!

3 comments

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!

0

I actually solved it by using script.Parent but your input helped me a bit! Thanks alot!

0

Glad to hear that!

This discussion is preserved as it was. New answers, comments, and votes are closed.