Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this script do something and then immediately revert it?

Asked by 5 years ago
Edited 5 years ago
local gui = script.Parent

gui.MenuEnabled.Value = true

function changeAngle()
    local player = game:GetService("Players").LocalPlayer
    local partAngleFolder = workspace.MainMenuAngles
    local currentCamera = workspace.Camera
    local currentPart = partAngleFolder["MainMenuAngle"..math.random(1, #partAngleFolder:GetChildren())]

    currentCamera.CameraType = "Scriptable"
    currentCamera.CFrame = currentPart.CFrame
end

gui.MouseButton1Up:Connect(function()
    gui.MenuEnabled.Value = false
    gui.Parent.Enabled = false
    gui.Parent.Parent.Stats.Enabled = true
    gui.Parent.Parent.DinoInfo.Enabled = true
    gui.Parent.Parent.LifeStats.Enabled = true
end)

wait(0.1)

changeAngle()

while gui.MenuEnabled.Value == true do 
    changeAngle()
    wait(3)
end

for some reason it will make the guis appear and the angle will stop changing, but only for a second, then it will just deactivate the guis, put the main menu back, and then start changing angles again... been trying to find this out for 2 days and nothing i try works. during testing, i found out that the MenuEnabled value changes back to true as well, and i have no idea why.

0
it seems like that while true do loop is looping, because nothing has un-click the gui vergelrady 0 — 5y

Answer this question