I’m trying to make this script check if a Frame is visible before letting it do anything.
Its printing that the ui is visible both when it is and when its not.
I searched it up and it looks like nobody has the problem.
Here is the code
script.Parent.Touched:Connect(function(hit)
print("go")
local random = math.random(1, 3)
local char = hit.Parent
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
print("humanoid")
local plr = game.Players:FindFirstChild(char.Name)
if plr.PlayerGui.tut.Frame.Visible == false then
print("is not visible")
if random == 1 then
char:MoveTo(game.Workspace.spawn1.Position)
elseif random == 2 then
char:MoveTo(game.Workspace.spawn2.Position)
elseif random == 3 then
char:MoveTo(game.Workspace.spawn3.Position)
end
char.force.Visible = true
local b = game.ReplicatedStorage.HK416:Clone()
b.Parent = plr.Backpack
local c = game.ReplicatedStorage.MP5:Clone()
c.Parent = plr.Backpack
local d = game.ReplicatedStorage.R700:Clone()
d.Parent = plr.Backpack
local e = game.ReplicatedStorage.USP:Clone()
e.Parent = plr.Backpack
wait(5)
char.force:Destroy()
else
print("is visible")
end
end
end)
Thank you for helping