I made a thing in my roblox game where if you trigger a proximity prompt a gui should be enabled and you cant jump, but when I trigger the proximity prompt it doesnt show up and i can still jump is this an issue with how i active the proximity prompt or am I doing something else incorrectly?
this is my code
01 | proximityPrompt = game.Workspace.pizzadougharea.CuttingBoard:WaitForChild( "ProximityPrompt" ) |
02 | timingGUI = game.StarterGui.doughtiming |
03 |
04 | players = game:GetService( "Players" ) |
05 | starterPlayer = game:GetService( "StarterPlayer" ) |
06 | local userInput = game:GetService( "UserInputService" ) |
07 |
08 | proximityPrompt.Triggered:Connect( function () |
09 | timingGUI.Enabled = true |
10 | starterPlayer.CharacterJumpHeight = 0 |
11 |
12 | if input.KeyCode = = Enum.KeyCode.Space then |
13 | print ( "player pressed space" ) |
14 | timingGUI.Enabled = false |
15 | end |
16 |
17 | end ) |
StarterGui is where gui gets transferred into every player's playergui when the game starts, so you can't use game.StarterGui on the client. You should've instead referenced the localplayer's gui. Also, that's not how you detect a key press.
01 | enabled = false |
02 | proximityPrompt = game.Workspace.pizzadougharea.CuttingBoard:WaitForChild( "ProximityPrompt" ) |
03 | timingGUI = game.Players.LocalPlayer.PlayerGui.doughtiming |
04 |
05 | players = game:GetService( "Players" ) |
06 | starterPlayer = game:GetService( "StarterPlayer" ) |
07 | local userInput = game:GetService( "UserInputService" ) |
08 |
09 | proximityPrompt.Triggered:Connect( function () |
10 | enabled = true |
11 | timingGUI.Enabled = true |
12 | starterPlayer.CharacterJumpHeight = 0 |
13 |
14 | end ) |
15 | userInput.InputBegan:Connect( function (input) |
01 | enabled = false |
02 | proximityPrompt = game.Workspace.pizzadougharea.CuttingBoard:WaitForChild( "ProximityPrompt" ) |
03 | timingGUI = game.Players.LocalPlayer.PlayerGui.doughtiming |
04 |
05 | players = game:GetService( "Players" ) |
06 | starterPlayer = game:GetService( "StarterPlayer" ) |
07 | local userInput = game:GetService( "UserInputService" ) |
08 |
09 | proximityPrompt.Triggered:Connect( function () |
10 | enabled = true |
11 | timingGUI.Enabled = true |
12 | timingGUI.Frame.visible = true |
13 | starterPlayer.CharacterJumpHeight = 0 |
14 |
15 | end ) |