How do I make it so that I can change a client's UI?

Hello! I’m trying to make a learning game on how you can protect your ROBLOX account, I’m making a NPC that will guide you along the way and I need to make it so that for the Bacon Hairs text that it will come up for that client only and I don’t have to go to starter GUI to define the players GUI

Here’s the Script RN

local ProximityPrompt = script.Parent

local BaconHairGUI = game.StarterGui.BaconGui

ProximityPrompt.Triggered:Connect(function()
	
end)

You want to use remote events in this situation. When a player triggeres the ProximityPrompt, a remote event will be fired to the client. And then the client will do the rest of the work.

Heres an example:
You want to insert a remote event in ReplicatedStorage and name it to BaconEvent. Then you use the following code below for your server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("BaconEvent")
local Prompt = script.Parent

Prompt.Triggered:Connect(function(player)
   Event:FireClient(player)
end)

Then you want to insert a LocalScript in your Gui that you want the player who triggered the ProximityPrompt to see.
Then use the following code below:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("BaconEvent")

Event.OnClientEvent:Connect(function()
   -- Your code for gui
end)
1 Like

Why doesn’t the player have any properties?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("BaconHairQuest1")

Event.OnClientEvent:Connect(function(player)
	player.
end)

This gets a syntax error for some reason

@BabyNinjaTime the script errors

  13:16:02.520  OnClientEvent can only be used on the client  -  Server - RemoteEventHandler:5
  13:16:02.520  Stack Begin  -  Studio
  13:16:02.521  Script 'ServerScriptService.RemoteEventHandler', Line 5  -  Studio - RemoteEventHandler:5
  13:16:02.521  Stack End  -  Studio
  13:16:19.140  0.5, 0.5  -  Server
  13:16:19.742  0.5, 0.5  -  Client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BaconHairText = game.StarterGui.BaconGui.DialogeFrame.TextLabel
local Event = ReplicatedStorage:WaitForChild("BaconHairQuest1")

Event.OnClientEvent:Connect(function()
	game.StarterGui.BaconGui.DialogeFrame.Visible = true
	
	local function typewrite(object, text)
		for i = 1,#text,1 do
			object.Text = string.sub(text,1,i)
			wait(0.05)
		end
	end
end)

typewrite(BaconHairText, "Hello! Im Bacon, Do you need something?")

The second code I have given is meant to be in a LocalScript, which should be somewhere inside your gui
This code should be in a LocalScript:

Also, when firing a remote event using FireClient(), there is no first argument that includes the player. The first argument will only be whatever we send to the client, not the player. And in this case, there are no arguments whatsoever.

1 Like

Why does the typewriter effect not work?

  13:31:00.471  Players.NubblyFry.PlayerGui.BaconHairGUIManager:16: attempt to call a nil value  -  Client - BaconHairGUIManager:16
  13:31:00.472  Stack Begin  -  Studio
  13:31:00.472  Script 'Players.NubblyFry.PlayerGui.BaconHairGUIManager', Line 16  -  Studio - BaconHairGUIManager:16
  13:31:00.472  Stack End  -  Studio
1 Like

Could you show your current code in your LocalScript?

1 Like
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BaconHairText = script.Parent.BaconGui.DialogeFrame.TextLabel
local Event = ReplicatedStorage:WaitForChild("BaconHairQuest1")

Event.OnClientEvent:Connect(function()
	script.Parent.BaconGui.DialogeFrame.Visible = true

	local function typewrite(object, text)
		for i = 1,#text,1 do
			object.Text = string.sub(text,1,i)
			wait(0.05)
		end
	end
end)

typewrite(BaconHairText, "Hello! Im Bacon, Do you need something?")
1 Like

Can I see the hierarchy of your gui?

Everything works, its just the type writer effect that’s not working.

Screenshot 2021-08-17 133855

Oh, I see the problem. Move the typewrite function out of the event. You’re probably getting “unknown global ‘typewrite’”.

1 Like

I think i found the issue.
Try this code for your local script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("BaconHairQuest1")
local BaconHairText = script.Parent.BaconGui.DialogeFrame:WaitForChild("TextLabel")

local function typewrite(object, text)
	for i = 1,#text,1 do
		object.Text = string.sub(text,1,i)
		wait(0.05)
	end
end

Event.OnClientEvent:Connect(function()
	script.Parent.BaconGui.DialogeFrame.Visible = true
	typewrite(BaconHairText, "Hello! Im Bacon, Do you need something?")
end)
1 Like

Theirs a bug, whenever I spam E, the text starts to replay at rapid speeds and even copies itself and breaks

You should have the prompt disabled when triggered. Then make the script wait for until the text stops, and reenable the proximityprompt

1 Like

You should add debounce here.

1 Like