So if I make a local script, make it a child of the ‘TextLabel’ in startedGUI
local BrickTouch = game.Workspace.BrickTouch
local debounce = true
local function doSomething(otherPart)
if not debounce then return nil end
local player = game:GetService("Players"):GetPlayerFromCharacter(otherPart.Parent)
if player then
player.PlayerGui.DialogueUi.TextLabel.Visible = true
debounce = false
task.wait(2)
debounce = true
end
end
BrickTouch.Touched:Connect(doSomething)
I guess that could work, but you get the issues with waiting on replication. Try this code, which is a Script as a child to the Part:
local players = game:GetService("Players")
local part = script.Parent
local debounce = true
local function doSomething(otherPart)
if not debounce then return nil end
local player = players:GetPlayerFromCharacter(otherPart.Parent)
if player then
player.PlayerGui.DialogueUi.TextLabel.Visible = true
debounce = false
task.wait(2)
debounce = true
end
end
part.Touched:Connect(doSomething)
Instead of getting it from the starterGui, start your script like this:
local player = game:GetService("Players").LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local gui = PlayerGui:WaitForChild("DialogueUI")