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

Gui functions and keydown functions not doing anything at all?

Asked by
AltNature 169
6 years ago

Pretty simple to understand ; I have a seat in a boat ; I have the boat in a huge transparent block with cancollide off and anchor on . when you enter the block it checks if ur seated then if u are pops up a Gui and if you press e while it is on screen it dissapears and pops a new gui… you can see the script ;

01--// Variables \\--
02 
03local part = script.Parent
04 
05local plr = game.Players.LocalPlayer
06 
07local mouse = plr:GetMouse()
08 
09local f = false
10 
11local t = true
12 
13--gui variables
14 
15local eGui = game.StarterGui.pressEgui.eGui
16 
17local basic = game.StarterGui.ChooseDifficulty.BasicButton
18 
19--// Actions \\--
20 
21   
22 
23part.Touched:Connect(function()
24 
25if plr.Seated == t then
26 
27eGui.Visible = t
28 
29end
30 
31end)
32 
33   
34 
35mouse.KeyDown:Connect(function(Key)
36 
37if Key == "e" then
38 
39basic.Visible = t
40 
41end
42 
43end)
44 
45   
46 
47basic.MouseButton1Click:Connect(function()
48 
49basic.Visible = f
50 
51end)

if u need any more info to reslove my issue please comment
nothing in output comes up :/

0
key down is bad use user input service User#24403 69 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Your gui variables seems to be wrong which is line #15 and #17, You stored a service which is StarterGui in both variables. So it is changing the visibility of your eGui in the service not locally. So, store game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui") so it would change locally.

1
Along with this answer, local scripts don't work in the workspace, so you can either move your script to StarterPlayerScripts and redefine your variables or use a remote event MegaManSam1 207 — 6y
0
Agreed. ++ NickAtNick 163 — 6y
Ad

Answer this question