Script correction and execution challenge

What they gave me was a script that when typing a word in the roblox chat opens a GUI with a text and after a predetermined time the GUI closes.
I also need how and where to place the script and to create the GUI.

I would also like to have a distance to say the word and open the GUI, you can use as a reference a Part or a simple block.

This is the script provided

local ChatService = game:GetService("Chat")

local GUI = -- Insert the GUI object you want to open here
local keyword = "tupalabra" -- Replace "tupalabra" with the word you want to detect in chat
local displayTime = 5 -- Replace 5 with the number of seconds you want the GUI to be displayed. antes de cerrarse automáticamente

ChatService.ChatProcessed:Connect(function(player, message, channel)
    if message:lower() == keyword then
        -- Open the GUI here
        GUI.Enabled = true
        wait(displayTime)
        -- Closes the GUI after a certain time
        GUI.Enabled = false
    end
end)

1 Like

The code should be inside a local script inside StarterGui. The gui also should be placed inside StarterGui. I’m guessing the gui intended is a ScreenGui. I’m guessing you’re new to guis so here’s a tutorial.

When you say this, i’m guessing you also want the player to be within a certain distance to an object in order for the gui to appear

local ChatService = game:GetService("Chat")

local GUI = -- Insert the GUI object you want to open here
local part = -- Part that will be used as a reference point to calculate the distance
local keyword = "tupalabra" -- Replace "tupalabra" with the word you want to detect in chat
local distanceRequired = 10 -- Distance required for the gui to open
local displayTime = 5 -- Replace 5 with the number of seconds you want the GUI to be displayed. antes de cerrarse automáticamente

ChatService.ChatProcessed:Connect(function(player, message, channel)
	local character = player.Character
	if not character then return end
	if message:lower() == keyword and (part.Position - character:FindFirstChild("HumanoidRootPart").Position).Magnitude <= distanceRequired then
		-- Open the GUI here
		GUI.Enabled = true
		task.wait(displayTime)
		-- Closes the GUI after a certain time
		GUI.Enabled = false
	end
end)
1 Like
local GUI = Instance.new('ScreenGui')
GUI.Parent = game.ServerStorage
GUI.Enabled = false

local frame = Instance.new('Frame')
frame.Size = UDim2.new(0.5,0,0.5,0)
frame.Position = UDim2.new(0.5,0,0.5,0)
frame.AnchorPoint = Vector2.new(0.5,0.5)
frame.BorderSizePixel = 0
frame.Parent = GUI

local zone = Instance.new('Part') -- You can replace this with any part. I.E. workspace.Part
zone.Size = Vector3.new(4,1,4) -- You also don't need a part for the zone at all, I just decided to do it this way.
zone.Anchored = true
zone.CanCollide = false
zone.Transparency = 1
zone.Name = "Zone"
zone.Position = Vector3.new(0,0,0)
zone.Parent = workspace

local keyword = "tupalabra"
local displayTime = 5
local distance = 10

game:GetService('Players').PlayerAdded:Connect(function(plr)
	local UI = GUI:Clone()
	UI.Parent = plr.PlayerGui
	plr.Chatted:Connect(function(msg)
		if string.lower(msg) == 'tupalabra' and (zone.Position - 
plr.Character.HumanoidRootPart.Position).magnitude <= distance then
			UI.Enabled = true 
			task.wait(displayTime)
			UI.Enabled = false
		end
	end)
end)

I know how to create GUI, but what I find difficult are the scripts.
I did everything you asked me to do but I have my doubts because it didn’t work.
First doubt
-The local script must be inside the StarterGui or ScreenGui.
What are you trying to say when you tell me to insert the gui? what do I have to put in this line?

What do I put in this line of the code, the name of my Part? if so, how do I put it? with parenthesis?

Or we can make it easier, you can send it to me as a complete model or you can also send it to me as a file**

I’d just put the gui inside the ScreenGui to make it simple.
Here’s what you define the variables as:

local GUI = script.Parent
local part = workspace["Part"] -- Put the name of the part inside the quotation marks

I’d highly recommend learning the basics of scripting. TheDevKing has a good series on roblox scripting.

If you still have problems after, then let me know.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.