#how could i make the image labels and text labels load better
1 messages · Page 1 of 1 (latest)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local ui = script.Parent
local frame = ui:WaitForChild("DialogueFrame")
local nameLabel = frame:WaitForChild("NameLabel")
local portrait = frame:WaitForChild("Portrait")
local dialogueText = frame:WaitForChild("DialogueText")
local btn1 = frame.ButtonHolder.Responce1
local btn2 = frame.ButtonHolder.Responce2
local btn1Conn
local btn2Conn
dialogueText.TextWrapped = true
local talking = false
local typeSound = ui:WaitForChild("TypeSound")
local function typeText(text)
dialogueText.Text = ""
for i = 1, #text do
dialogueText.Text = string.sub(text, 1, i)
typeSound:Play()
wait(0.000001) -- changes speed of text
end
end
function handleResponse(responseData)
if responseData.Type == "Close" then
hideUI()
elseif responseData.Type == "NextMessage" then
local newData = responseData.NextDialogue
if newData then
updateUI(newData)
end
else
warn("Unknown Response Type")
hideUI()
end
end
function openUI(data)
btn1.Text = ""
btn2.Text = ""
ui.Enabled = true
frame.Visible = true
updateUI(data)
end
function updateUI(data)
nameLabel.Text = data.Name
portrait.Image = data.Portrait
typeText(data.Dialogue)
btn1.Text = data.Responses[1].Text
btn2.Text = data.Responses[2].Text
if btn1Conn then btn1Conn:Disconnect() end
if btn2Conn then btn2Conn:Disconnect() end
btn1Conn = btn1.MouseButton1Click:Connect(function()
handleResponse(data.Responses[1])
end)
btn2Conn = btn2.MouseButton1Click:Connect(function()
handleResponse(data.Responses[2])
end)
btn1.TextWrapped = true
btn2.TextWrapped = true
end
** You are now Level 2! **
function hideUI()
task.delay(0.1, function()
talking = false
frame.Visible = false
ui.Enabled = false
btn1.Text = ""
btn2.Text = ""
end)
end
game:GetService("ProximityPromptService").PromptTriggered:Connect(function(prompt,player)
if talking then return end
talking = true
local npc = prompt.Parent:FindFirstChild("NPCName")
if not npc then return end
local dataModule = ReplicatedStorage.NPCData:FindFirstChild(npc.Value)
if not dataModule then return end
local npcData = require(dataModule)
openUI(npcData[npc.Value])
end)
It's better if you don't change the image through the script then
Instead make the image label visible to true or false whenever you want
I think this happens because it loads the image or something
Is your delay not just too long? I just skimmed it
What would be better to change the delay to?
Like, nothing
I assume the delay is whats causing the flash
Make it like 0.0001 or something
Again i havnt really read it
i tried this but nothing really changed the flash is still present
In HideUI? you have it set to 0.1 here
Yea
Idk, ask ai 💔