local gui = game.StarterGui.DialogueUi.TextLabel
local debounce = true
local function doSomething (otherPart)
if debounce and otherPart:FindFirstChildWhichIsA("Humanoid") then
debounce = false
gui.Enabled = true
wait(2)
debounce = true
end
end
gui.Touched:Connect(doSomething)
local gui = game.StarterGui.DialogueUI.TextLabel
local part = script.parent
local debounce = true
local function doSomething(otherPart)
if debounce and otherPart:FindFirstChildWhichIsA("Humanoid") then
debounce = false
gui.Visible = true
wait(2)
debounce = true
end
end
part.Touched:Connect(doSomething)
Touched gives the touched part as a parameter, not the character.
You’re editing the things in StarterGui, which do not replicate to PlayerGui until PlayerGui is refreshed (re-replicated, e.g. on join)
Try this:
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)
I’d recommend doing all GUI things client-side, using a RemoteEvent.