UI scripting error

function userinterface()
	game.StarterGui.ScreenGui.Frame.Transparency = 1
	game.StarterGui.ScreenGui.Frame.Active = false
	
	button.MouseButton1Click:Connect(userinterface())
	while true do wait()
	end

end


wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false

function teleport()
	if not debounce then
		debounce = true
		LowerTorso = player.Character.LowerTorso
		LowerTorso.CFrame = game.Workspace.CarSpawn.CFrame
	end
end

button.MouseButton1Click:Connect(teleport)
while true do wait()
	debounce = false
	wait(1)
end

the function userinterface is supposed to make game.startergui.frame invisible and not active when the imagebutton is clicked
theres no error in the code or output it just doesnt work. plz help

.Transparency is not a property of UI Frames, use the .Visible = true/false to change the visibility of UI objects.

Alternatively, if you need to fade the frame’s visibility, you can tween the .BackgroundTransparency property.

1 Like

why the hell are you calling the function in an event inside the function itself ??

1 Like

You also do

inside the userinterface() function, which means it will not be bound until the function is first called. Meaning the function never gets called. Move this outside the function in order to bind the event.

1 Like

You need to use game.Players.LocalPlayer.PlayerGui instead of StarterGui

2 Likes
local Player = game.Players.LocalPlayer

function userinterface()
	Player.PlayerGui.ScreenGui.Frame.Visible = false
	Player.PlayerGui.ScreenGui.Frame.Active = false
end

button.MouseButton1Click:Connect(userinterface())

wait(1)
button = script.Parent
local debounce = false

function teleport()
	if not debounce then
		debounce = true
		HumanRoot = Player.Character.HumanoidRootPart
		HumanRoot.CFrame = game.Workspace.CarSpawn.CFrame
	end
end

button.MouseButton1Click:Connect(teleport)
while true do wait()
	debounce = false
	wait(1)
end

Tried cleaning it up the best I can, hope this helps :slight_smile: