Hello! So im making this text command thing for my game. The issue is, the text command wont hide. I’ve been stuck on this for hours
my function
local function ProcessTextCommand()
for i, v in pairs(txt_cmds) do
if timer.Value:match(v.cmd) then
v.action()
displayed_timer = string.gsub(timer.Value ,v.cmd, "")
elseif timer.Value:match("rgb") then --- color
local arguments = timer.Value:split('/')
local color = arguments[2]
color = color:split(":")[1]
local full_cmd = string.format(":color-rgb/%s:", color)
print("full cmd: " .. full_cmd, "full string: " .. timer.Value)
selected_color = color
v.action()
print(string.match(timer.Value, full_cmd))
displayed_timer = timer.Value:gsub(full_cmd, "") -- issue here
else -- not found
displayed_timer = timer.Value
v.not_found()
end
end
end
my txt_cmds thing:
local txt_cmds = {
["rotate"] = {
["cmd"] = ":rotate:",
["not_found"] = RotateNotFound,
["action"] = RotateAction
},
["rgb_color"] = {
["cmd"] = ":color-rgb/:",
["not_found"] = RgbNotFound,
["action"] = RgbColor
}
}
my full script, plz help
--variables--
local selected_color = nil
local players = game:GetService("Players")
local tween_service = game:GetService("TweenService")
local displayed_timer = nil
local player = players.LocalPlayer
local is_playing = false
local round_assets = game:GetService("ReplicatedStorage"):WaitForChild("Assets"):WaitForChild("RoundAssets")
local values = round_assets:WaitForChild("Values")
local top = values:WaitForChild("Top")
local timer:StringValue = values:WaitForChild("Timer")
local top_ui = script.Parent.Top
local rotate_increment = 7.5
local timer_ui = script.Parent.Timer
-- tweens ---
local info = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
local rotate_goals = {
Rotation = -rotate_increment
}
local rotate_command_tween = tween_service:Create(timer_ui, info, rotate_goals)
local rotate_command_tween_reverse = tween_service:Create(timer_ui, info, {Rotation=rotate_increment})
local function RotateAction()
if not is_playing then
is_playing = true
rotate_command_tween:Play()
rotate_command_tween.Completed:Connect(function(playbackState)
if playbackState ~= Enum.PlaybackState.Cancelled then
rotate_command_tween_reverse:Play()
rotate_command_tween_reverse.Completed:Connect(function(state)
if state ~= Enum.PlaybackState.Cancelled then
rotate_command_tween:Play()
end
end)
end
end)
end
end
local function RotateNotFound()
is_playing = false
rotate_command_tween:Cancel()
rotate_command_tween_reverse:Cancel()
timer_ui.Rotation = 0
end
local function RgbColor()
timer_ui.TextColor3 = Color3.fromRGB(selected_color)
end
local function RgbNotFound()
timer_ui.TextColor3 = Color3.fromRGB(255, 255, 255)
end
local txt_cmds = {
["rotate"] = {
["cmd"] = ":rotate:",
["not_found"] = RotateNotFound,
["action"] = RotateAction
},
["rgb_color"] = {
["cmd"] = ":color-rgb/:",
["not_found"] = RgbNotFound,
["action"] = RgbColor
}
}
---functions---
local function ProcessTextCommand()
for i, v in pairs(txt_cmds) do
if timer.Value:match(v.cmd) then
v.action()
displayed_timer = string.gsub(timer.Value ,v.cmd, "")
elseif timer.Value:match("rgb") then --- color
local arguments = timer.Value:split('/')
local color = arguments[2]
color = color:split(":")[1]
local full_cmd = string.format(":color-rgb/%s:", color)
print("full cmd: " .. full_cmd, "full string: " .. timer.Value)
selected_color = color
v.action()
print(string.match(timer.Value, full_cmd))
displayed_timer = timer.Value:gsub(full_cmd, "") -- issue here
else -- not found
displayed_timer = timer.Value
v.not_found()
end
end
end
--- top
top_ui.Text = top.Value
top.Changed:Connect(function(property)
top_ui.Text = top.Value
end)
-- timer
ProcessTextCommand()
timer_ui.Text = displayed_timer
timer.Changed:Connect(function(property)
ProcessTextCommand()
timer_ui.Text = displayed_timer
end)
any help is appreciated. Thanks!