Help with jump script

Hi, I’m trying to make a script that will detect when the player has jumped and closed a GUI and it doesn’t work yet I don’t know why. I was wondering if I could please have some help with identifying the issue.

local UserInputService = game:GetService("UserInputService")

function onJumpRequest()
	print("detected")
	local frame = script.Parent
	script.frame.Visible = false
	print("Worked ")

	
end

UserInputService.JumpRequest:Connect(onJumpRequest)

Thank you for your help!

1 Like

frame.Visible = false will do for this

2 Likes

Thanks for the help! The problem I’m having is script won’t even detect when the player has jumped.

1 Like

Is this a local script? or server sided script

1 Like

Yep, it’s in a local script. Yet it is inside a screen GUI so that might be the issue

1 Like

Try putting it in starter player scripts

1 Like

It has to be in the GUI but I think I might just use bindable events instead since the script by its self works!

1 Like

What do you mean by the script itself?

Also it doesn’t have to be in the StarterGui. You can reference to the ui by doing game.Players.LocalPlayer.PlayerGui.StarterGui.Frame.Visible = false

e

repeat
	wait()
until
game.Players.LocalPlayer.Character

local Character = game.Players.LocalPlayer.Character

local Gui = script.Parent

Character:WaitForChild("Humanoid"):GetPropertyChangedSignal("Jump"):Connect(function()
	Gui.Enabled = false
end)
1 Like

Are you sure the frame is placed in the local script or do you want to reference the variable?

And the print shows on the output?

1 Like

Never mind I was able to make it work using bindable events. Thanks for the help!

1 Like

oh its a frame i thought its a screen gui

Gui.Visible… I mean

Try this out instead

local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

function onJumpRequest()
	print("detected")
	local frame = script.Parent
	frame.Visible = false
	print("Worked ")
end

humanoid.Jumping:Connect(onJumpRequest)
1 Like