Hello developers.
I have some issues with some of my scripts, that I don’t know how to fix them so I made this post.
- problem Camera FieldOfView is glitching due to a lot of scripts use FOV in it so that’s why, and I don’t know how to fix that without deleting scripts. If anyone knows how to fix that please reply. thanks.
- I made a script that removes Roblox core guis when frame is on screen, but when I close gui chat and other core GUI doesn’t show anymore, I have no idea why’s that so I am gonna leave the script down below for anyone to check and tell me if anything is wrong, it would be very helpful and friendly of you. thanks.
script for removing guis:
local CarSpawner = script.Parent.Parent.Parent:WaitForChild("AllOnScreenGui")
local Sections = script.Parent.Sections:GetChildren()
local StarterGui = game.StarterGui
local hide_gui = {Enum.CoreGuiType.Chat, Enum.CoreGuiType.Backpack, Enum.CoreGuiType.EmotesMenu, Enum.CoreGuiType.PlayerList}
local visibles = {}
for i, g in pairs(hide_gui) do
visibles[g] = StarterGui:GetCoreGuiEnabled(g)
end
function Check()
if script.Parent.Position == UDim2.new(0.5,0,3,0) then
for i, g in pairs(hide_gui) do
StarterGui:SetCoreGuiEnabled(g, visibles[g])
end
CarSpawner.Enabled = true
else
for i, g in pairs(hide_gui) do
visibles[g] = StarterGui:GetCoreGuiEnabled(g)
StarterGui:SetCoreGuiEnabled(g, false)
end
for i, v in pairs(Sections) do
if v:IsA("Frame") or v:IsA("ScrollingFrame") then
v.Visible = false
end
end
CarSpawner.Enabled = false
end
end
Check()
script.Parent.Changed:Connect(Check)
have a good day!
Can anyone help please? I am waiting days already.
I think because in your else statement you are setting the CoreGui to false on all the CoreGui elements in your hide_gui table.
I assume you wanted to make them true when the frame isn’t visible.
[edit] Actually the else may be for when your frame isn’t visible…is this the case or no?
That is the case, yes. whenever the frame is at a certain position core should disappear/appear
The problem here is once they get set to false, they never stop being false. Following your script execution order, this is what happens.
- Script stores CoreGuiEnabled into visibles table
1a. All CoreGui are most likely stored as true on first run
- Script runs Check()
2a. If frame is open - Sets each CoreGui to true based on 1a
2b. If frame is closed - Gets each CoreGui as true based on 1a and stores in visibles
2b1. Then Sets each CoreGui as false no matter what
- .Changed happens
3a. If frame is open - Sets each CoreGui to true based on 2b
3b. if frame is closed - Gets each CoreGui as false based on 2b1 and stores in visibles
3b1. Then Sets each CoreGui as false no matter what
Here lies the problem now that they are set as false and visibles is set as false you will always be setting and getting them as false after this iteration has completed.
Suggestion to follow would be, if I understand you correctly in wanting your CoreGui list enabled when the frame is gone and disabled when the frame is on screen, is to simply do
if OnScreen then
for i, g in pairs(hide_gui) do
StarterGui:SetCoreGuiEnabled(g, true)
end
else
for i, g in pairs(hide_gui) do
StarterGui:SetCoreGuiEnabled(g, false)
end
end
Thank you very much, this helped a lot. but if you maybe know how to stop overlapping FieldOfView scripts I would be even happier, I am a little beginner at scripting that’s why I don’t know how to fix problems a lot. If you don’t know It’s okay I am still thankful.