I put a button (local Button) on a brick and its supposed to open a frame (Frame) on the screen when pressed (and vise versa, if its already open) All the objects are present in the Workspace and the frame (Frame) is already preset to not visible.
local Button = script.Parent.SurfaceGui.Change.ChangeButton
Frame = script.Parent.Parent.RollingChair.Seat.ScreenGui.Frame.Visible
function onClick()
if Frame.Visible == false then
Frame.Visible = true
elseif Frame.Visible == true then
Frame.Visible = false
end
end
Button.MouseButton1Click:connect(onClick)
Note: You must be sitting in the Seat in order to see the frame on the ScreenGui.
When I'm sitting on the seat and press the button (local Button), the frame on the ScreenGui does not become visible.
(Below is the script in the seat to activate the ScreenGui that contains the frame.
a = script.Parent.ScreenGui
function onChildAdded(child)
if child.Name == "SeatWeld" then
if child.Part1.Name == "HumanoidRootPart" then
local player = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
if player ~= nil then
a.Parent = player.PlayerGui
a.Bus.Value = script.Parent.Parent.Parent
end
end
end
end
function onChildRemoved(child)
if child.Name == "SeatWeld" then
if a ~= nil then
a.Parent = script.Parent
end
end
end
script.Parent.ChildAdded:connect(onChildAdded)
script.Parent.ChildRemoved:connect(onChildRemoved)
