I want to make a text system like Isle’s, where when an action is performed, it makes dialogue appear, and if it is repeated, depending on where the text is, it says “Action Text [x2]”, the problem I’m having is I can’t figure out how to differentiate from what is the current text I’m using from the one I’m comparing to, which has given me huge issues.
I’ve tried using an IntValue named “Current” but the problem is, when I try to delete the IntValue, it just doesn’t destroy it.
The weird part is when I put “current:Destroy()” at the top, like this, it works.
game.ReplicatedStorage.Dialogue.OnClientEvent:Connect(function(text, color)
print(text)
local clone = textFrame:Clone()
clone.Parent = script.Parent
clone.Name = text
clone.TextLabel.Text = text
clone.TextLabel.TextColor3 = color
local current = Instance.new("IntValue")
current.Name = "Current"
current.Parent = clone
current:Destroy() -- here
But if I put it below everything else (which is where I need it), it doesn’t delete the IntValue.
game.ReplicatedStorage.Dialogue.OnClientEvent:Connect(function(text, color)
print(text)
local clone = textFrame:Clone()
clone.Parent = script.Parent
clone.Name = text
clone.TextLabel.Text = text
clone.TextLabel.TextColor3 = color
local current = Instance.new("IntValue")
current.Name = "Current"
current.Parent = clone
if script.Parent[text] then
if script.Parent[text].Current then return end
if script.Parent[text].Position == UDim2.new(0.5, 0, 0.5, 0) then
local thing = script.Parent[text]
if thing:FindFirstChild("RepeatCounter") then
thing.RepeatCounter.Value += 1
thing.Visible = true
thing.TextLabel.Text = text.." [x"..tostring(thing.RepeatCounter.Value).."]"
else
local repeatCounter = Instance.new("IntValue")
repeatCounter.Name = "RepeatCounter"
repeatCounter.Parent = thing
thing.RepeatCounter.Value += 1
thing.Visible = true
thing.TextLabel.Text = text.." [x"..tostring(thing.RepeatCounter.Value).."]"
end
end
end
current:Destroy()
for _, v in pairs(script.Parent:GetChildren()) do
if v:IsA("Frame") then
if v.Name ~= text then
local pos = UDim2.new(v.Position.X.Scale, v.Position.X.Offset, v.Position.Y.Scale, v.Position.Y.Offset)
v:TweenPosition(pos + UDim2.new(0, 0, 0, -30), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.3, true)
end
end
end
current:Destroy() -- here
end)
If theres any way to fix this I’d like to know.