#how could i make the image labels and text labels load better

1 messages · Page 1 of 1 (latest)

solid plinth
#

i'm not too sure how to fix the flicker that occurs when the image label is changed or becomes visible or the kinda of odd way the text looks when loading for lack of better phrasing

#

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

sour trellisBOT
#

studio** You are now Level 2! **studio

solid plinth
#

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)

slow shadow
#

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

viral hamlet
#

???

#

He's buggin

viral hamlet
solid plinth
viral hamlet
#

I assume the delay is whats causing the flash

#

Make it like 0.0001 or something

#

Again i havnt really read it

solid plinth
viral hamlet
solid plinth
viral hamlet
slow shadow
#

Dude, he literally has to make an image label with the image id and then make it invisible and visible whenever he wants

#

Because he's changing the image id in the script, it will make the image load