You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
-I have some frames that needs to go left or right as the player presses Q and E. -
What is the issue? Include screenshots / videos if possible!
-The issue is that tweens do not happen fast enough as in it looks laggy.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
-I did try to use coroutines but it was for naught.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
- Here are the scripts(these scripts are little versions of the real ones.)
Server script(Named MainLogic)
local RS = game:GetService("ReplicatedStorage")
local P = game:GetService("Players")
local UiPrompt = RS.UiPrompt
local LocalResponse = RS.LocalResponse
local responses = {}
LocalResponse.OnServerEvent:Connect(function(plr, response)
print(response)
response[plr.Name] = response
end)
task.wait(12)
while true do
print("Fired!")
UiPrompt:FireAllClients()
task.wait(50)
responses = {}
end
local script
local TS = game:GetService("TweenService")
local RS = game:GetService("ReplicatedStorage")
local CAS = game:GetService("ContextActionService")
local ui = script.Parent
local BaseFrame = ui.BaseFrame
local Timer = BaseFrame.Timer
local UiPrompt = RS:WaitForChild("UiPrompt")
local LocalResponse = RS:WaitForChild("LocalResponse")
local framePosDic = {
["-2"] = {["Position"] = UDim2.new(-.3,0,.5,0), ["Size"] = UDim2.new(.18,0,.7,0)},
["-1"] = {["Position"] = UDim2.new(.1,0,.5,0), ["Size"] = UDim2.new(.18,0,.7,0)},
["0"] = {["Position"] = UDim2.new(.5,0,.5,0), ["Size"] = UDim2.new(.23,0,.9,0)},
["1"] = {["Position"] = UDim2.new(.9,0,.5,0), ["Size"] = UDim2.new(.18,0,.7,0)},
["2"] = {["Position"] = UDim2.new(1.3,0,.5,0), ["Size"] = UDim2.new(.18,0,.7,0)}
}
local Tr_Info = TweenInfo.new(.3, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0, false, 0)
local scope = 0
local function Tweener(givenInstance)
TS:Create(givenInstance, Tr_Info, {Position = framePosDic[givenInstance.Name]["Position"], Size = framePosDic[givenInstance.Name]["Size"]}):Play()
end
local function oneLeft()
scope -= 1
for i, v in ipairs(BaseFrame:GetChildren())do
if v:IsA("Frame") then
local num = tonumber(v.Name)
if num then
num -= 1
v.Name = tostring(num)
end
end
end
end
local function oneRight()
scope += 1
for i, v in ipairs(BaseFrame:GetChildren())do
if v:IsA("Frame") then
local num = tonumber(v.Name)
if num then
num += 1
v.Name = tostring(num)
end
end
end
end
local function Frames(Table:table): nil
for i,v in ipairs(Table)do
Tweener(v)
end
end
local function updateFrames(): nil
local frames: table = {}
for i, v in ipairs(BaseFrame:GetChildren())do
if v:IsA("Frame") and v.Name ~= "Selector" then
table.insert(frames, v)
--TS:Create(v, Tr_Info, {Position = FramePosDic[v.Name]["Position"], Size = FramePosDic[v.Name]["Size"]}):Play()
end
coroutine.resume(coroutine.create(Frames), frames)
task.wait(.5)
if BaseFrame:FindFirstChild("3") then
local Cl = BaseFrame:FindFirstChild("3")
Cl.Name = "-2"
Cl.Position = framePosDic[Cl.Name].Position
Cl.Size = framePosDic[Cl.Name].Size
Cl:ClearAllChildren()
--placerWithScope(Cl, scope)
elseif BaseFrame:FindFirstChild("-3") then
local Cl = BaseFrame:FindFirstChild("-3")
Cl.Name = "2"
Cl.Position = framePosDic[Cl.Name].Position
Cl.Size = framePosDic[Cl.Name].Size
Cl:ClearAllChildren()
--placerWithScope(Cl, scope)
end
end
end
local function actionHandler(actionName, inputState, inputObject)
if actionName == "Q" then
if inputState == Enum.UserInputState.Begin then
oneLeft()
updateFrames()
end
elseif actionName == "E" then
if inputState == Enum.UserInputState.Begin then
oneRight()
updateFrames()
end
end
end
UiPrompt.OnClientEvent:Connect(function()
print("Ui prompt taken!")
local whileCount = 0
CAS:BindAction("Q", actionHandler, false, Enum.KeyCode.Q)
CAS:BindAction("E", actionHandler, false, Enum.KeyCode.E)
while true do
if whileCount > 30 then
LocalResponse:FireServer("Response!")
break
end
task.wait(.25)
if (whileCount % 1) == 0 then
Timer.Text = math.abs(whileCount - 30)
end
whileCount += .25
end
CAS:UnbindAction("Q")
CAS:UnbindAction("E")
end)
Here is a screenshot of the explorer for just in case.
The tweens just don’t work simultaneously. So if you have a way please answer.