this is kinda hard to make a question about cuz i dont really know what the question should be but heres the context. im trying to make a model rotate left when left shift is pressed and when left shift is pressed again it turns right and it repeats kind of like left right left right left right
this is the code
local DisconnectRemoteEvent = true local RotateModel_Left = true local function RotateTheModel_Left() workspace.Model:SetPrimaryPartCFrame(workspace.Model:GetPrimaryPartCFrame()*CFrame.fromEulerAnglesXYZ(0,0.025,0)) end local function RotateTheModel_Right() workspace.Model:SetPrimaryPartCFrame(workspace.Model:GetPrimaryPartCFrame()*CFrame.fromEulerAnglesXYZ(0,-0.025,0)) end RemoteEvent.OnServerEvent:Connect(function() DisconnectRemoteEvent = false repeat wait() if RotateModel_Left == true then RotateTheModel_Left()print("Ok!") else RotateTheModel_Right()print("Ok!!!") end until DisconnectRemoteEvent == true print("HOLY ") RotateModel_Left = false end) game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() DisconnectRemoteEvent = true print("SON ") end)
im stuck on line 19 above where i dont really know what to do and im trying to do something similar to the code below that i made(line 11 and line 17) to loop the directioin the model is turning
the problem is the code above just makes the model turn left once,stops then turn right once,stops and now you can only do turn right,stop and the loop doesnt repeat and i have no idea how to get pass line 19 to make it loop left and right
Note:the code below works perfectly fine by the way
local RemoteEvent = game.ReplicatedStorage.RemoteEvent1 local REMOTEEVENT = game.ReplicatedStorage.RemoteEvent2 local True = true local False = false RemoteEvent.OnServerEvent:Connect(function() local Model = workspace.model if False == false then while True do Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame()*CFrame.fromEulerAnglesXYZ(0,0.025,0)) wait() end False = true else while True do Model:SetPrimaryPartCFrame(Model:GetPrimaryPartCFrame()*CFrame.fromEulerAnglesXYZ(0,-0.025,0)) wait() end False = false end end) REMOTEEVENT.OnServerEvent:Connect(function() True = false wait() True = true end)
i swapped to using repeat loops cuz i thought it would reduce the number of steps the game needs to run(which means it runs faster) and since i dont really know how to read steps the code is taking i just took a path that might have less moving parts but i dont know if its true or not
i do know what the code is doing
any tips would be cool