Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Pressing E not making Gui visible but no errors?

I'm making an ATM machine for a roleplay game I'm working on. I made an "E to interact" and it worked with print so I replaced it with making the ATM Gui visible. It didn't work and there wasn't errors. I tried debugging and it came out positive. My code is a LocalScript:

local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local UIS = game:GetService("UserInputService")
local Atm = game.Workspace.Atm

UIS.InputBegan:Connect(function(keyCode)
	if keyCode.keyCode == Enum.KeyCode.E then
		if (Atm.Position - HumanoidRootPart.Position).magnitude <10 then
			game.StarterGui.ScreenGui.FinnianATM.Visible = true
			print("Worked")
		end
	end
end)

1 comment

0

The error that I assume is on line 7, where it talks about the ATM. You can't get the ATM position, you can only get the position of one part inside of the ATM, considering if it's a model or not. If it is a model, make a HitBox part that is the size of the ATM and make it transparent, and no Collidable and then use that position for the magnitude.

3 answers

✓ Accepted answer

Instead of using "Visible = True", I normally Use "Enabled = True" or Enabled = False".

9 comments

0

Could you explain how I would go about using that? (I've never used enabled before)

0

Enabled is a ScreenGUI property where you can have all the components of the GUI Enabled or Disabled.

0

Enabled Just means that the "Gui" is allowed to be Used or Not. and it also sets the Visibility respectively.

0

It still didn't work again, no errors

0

where did you put your local script?

0

oh wait omg im so dumb i put it in startergui lol I can just do script.parent.screengui lemme try it

0

Can someone help me?

0

I'll still post your answer as worked thanks for the help

0

Np :)

if keyCode.keyCode == Enum.KeyCode.E then

to

if keyCode.keyCode == Enum.KeyCode.e then

probably

1 comment

0

No it isn't that because it's working with print

local UIS = game:GetService("UserInputService")
local ATMHitBox = game:GetService("Workspace"):FindFirstChild("ATM").HitBox
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

wait(0.25) --Wait For The Character To FULLY Load In

local HRP = Character:FindFirstChild("HumanoidRootPart")

UIS.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.E then
		if (ATMHitBox.Position - HRP.Position).Magnitude < 10 then
			--Whatever You Want To Happen
			print("Works")
		end
	end
end)

This Also Works As Well

This discussion is preserved as it was. New answers, comments, and votes are closed.