so im making an easter egg in my game and there is a part that changes text label text But only for the player who touched the brick. Yes the script is in starter gui.
local part = game.Workspace.special.evenmorespecial.secret
part.Touched:Connect(function()
local text1 = "..."
local text2 = "why would someone like this come here?"
local text3 = "hmm?"
local text4 = "i guess you dont like to talk."
local text5 = "... or you are a bit shocked?"
local text6 = "you probably got here by accident... just like i did..."
local text7 = "well, i didn't see a single human for years!"
local text8 = "i'll reward you with the ability to spawn the green dirt."
local text9 = "bye!"
local text = game.StarterGui.TFlaniganDialogue.d1
wait(1)
for i = 1, #text1 do
text.Text = string.sub(text1, 1, i)
wait(0.04)
end
wait(3)
for i = 1, #text2 do
text.Text = string.sub(text2, 1, i)
wait(0.04)
end
wait(4)
for i = 1, #text3 do
text.Text = string.sub(text3, 1, i)
wait(0.04)
end
wait(3)
for i = 1, #text4 do
text.Text = string.sub(text4, 1, i)
wait(0.04)
end
wait(4)
for i = 1, #text5 do
text.Text = string.sub(text5, 1, i)
wait(0.04)
end
wait(3)
for i = 1, #text6 do
text.Text = string.sub(text6, 1, i)
wait(0.04)
end
wait(3)
for i = 1, #text7 do
text.Text = string.sub(text7, 1, i)
wait(0.04)
end
wait(3)
for i = 1, #text8 do
text.Text = string.sub(text8, 1, i)
wait(0.04)
end
wait(4)
for i = 1, #text9 do
text.Text = string.sub(text9, 1, i)
wait(0.04)
end
end)

3 comments
it says onclientevent can be only used on the client. do i have to do something with local scripts?
For server->client, use
remoteEvent.OnClientEventin a localscript(s) and useremoteEvent:FireClient(player)orremoteEvent:FireAllClients()in a server script. Client->Server should instead useremoteEvent:FireServer()in a localscript and useremoteEvent.OnServerEventin server scriptarticle better explaining how it works: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events