Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Pressing E not making Gui visible but no errors?

Asked by
8jxms 9
5 years ago

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:

01local HumanoidRootPart = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
02local UIS = game:GetService("UserInputService")
03local Atm = game.Workspace.Atm
04 
05UIS.InputBegan:Connect(function(keyCode)
06    if keyCode.keyCode == Enum.KeyCode.E then
07        if (Atm.Position - HumanoidRootPart.Position).magnitude <10 then
08            game.StarterGui.ScreenGui.FinnianATM.Visible = true
09            print("Worked")
10        end
11    end
12end)
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. killerbrenden 1537 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago

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

0
Could you explain how I would go about using that? (I've never used enabled before) 8jxms 9 — 5y
0
Enabled is a ScreenGUI property where you can have all the components of the GUI Enabled or Disabled. killerbrenden 1537 — 5y
0
Enabled Just means that the "Gui" is allowed to be Used or Not. and it also sets the Visibility respectively. ffancyaxax12 181 — 5y
0
It still didn't work again, no errors 8jxms 9 — 5y
View all comments (5 more)
0
where did you put your local script? ffancyaxax12 181 — 5y
0
oh wait omg im so dumb i put it in startergui lol I can just do script.parent.screengui lemme try it 8jxms 9 — 5y
0
Can someone help me? WN0820 11 — 5y
0
I'll still post your answer as worked thanks for the help 8jxms 9 — 5y
0
Np :) ffancyaxax12 181 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
1if keyCode.keyCode == Enum.KeyCode.E then

to

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

probably

0
No it isn't that because it's working with print 8jxms 9 — 5y
Log in to vote
0
Answered by 5 years ago
01local UIS = game:GetService("UserInputService")
02local ATMHitBox = game:GetService("Workspace"):FindFirstChild("ATM").HitBox
03local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
04 
05wait(0.25) --Wait For The Character To FULLY Load In
06 
07local HRP = Character:FindFirstChild("HumanoidRootPart")
08 
09UIS.InputBegan:Connect(function(key)
10    if key.KeyCode == Enum.KeyCode.E then
11        if (ATMHitBox.Position - HRP.Position).Magnitude < 10 then
12            --Whatever You Want To Happen
13            print("Works")
14        end
15    end
16end)

This Also Works As Well

Answer this question