Hello, I'm trying to make a simple function where, when the TextButton is clicked, it will cause the player to jump. However, upon clicking it, nothing happens. I made it print something upon clicking it, and it prints, but doesn't make the player jump. I'm not sure what's wrong with it.
button = script.Parent
mobile = game:GetService('UserInputService').TouchEnabled
if mobile == true then
button.Visible = true
end?
function jump()
game.Players.LocalPlayer.Character.Humanoid.Jump = true
end
button.MouseButton1Down:Connect(jump)
It's also a button that's only meant to display on mobile, which also doesn't work. However, after removing that portion of the script, nothing happens still. What's the problem?

4 comments
well for one, there's a question mark after your end on line 6. if that still doesnt solve your problem, try changing line 9 to: game.Players.LocalPlayer.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping,true)
for some reason, a while back, setting the jump property to true worked in studio, but not in real servers. using SetStateEnabled worked the opposite however
@gioni01, I tried what you said and it didnt work in studio, so i posted an answer for what does work in studio, although your way might work on actual servers, idk
Whoops. The question mark must have been added while I was typing out the question. It's not in the actual script. Unfortunately, changing line 9 didn't work, either, though.