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)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("BaconHairQuest1")
Event.OnClientEvent:Connect(function(player)
player.
end)
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.
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
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?")
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)