Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script works in studio but not while playing the game on mobile app?

I don't really need this script but I want to learn why it does not work to prevent the problem from happening in other scripts. Basically the script works on PC and studio but not mobile (I am not sure about console). The script first checks that a value in the character, which should always have this value since it is in the starter character. This it the script:

script.Parent.Touched:connect (function(hit) --part is hit

if hit and hit.Parent and hit.Parent:FindFirstChild:("Humanoid") and hit.Parent.canjump.Value == true then

hit.Parent.Humanoid.Jump = true

hit.Parent.canJump.Value = false

end

end

Since this script is in the workspace, I think it must be some auto-jump (like the ones in lots of mobile games) on the mobile app that causes the player to jump up the block. Then the player goes down the other side and when the player comes back up (even with canJump false) The auto-jump activates, making it seem like the script was activated. Is there an auto-jump on the mobile app? If there is, how do you turn it off?

3 comments

0

Thanks for adding Value to canjump, I accidentally missed it when typing my program up. I think I figured it out on my own. I was testing my game with both a computer and a mobile device at the same time and noticed that the mobile device player jumps whenever it hits a block, even without the script. I think there must be a built in auto-jump in the mobile app. Am I right? How do you turn it off?

0

To turn it off, go into studio and click starterplayer. There in an option to disable auto jump for mobile

0

Thanks, I will try that to turn autojump off, that comment answers my question.

1 answer

✓ Accepted answer
script.Parent.Touched:connect (function(hit) --part is hit
	if hit and hit.Parent and hit.Parent:FindFirstChild:("Humanoid") and hit.Parent.canjump.Value == true then
		hit.Parent.Humanoid.Jump = true
		hit.Parent.canJump.Value = false	--Forgot to add value at the end
	end
end)

You may also want to add a debounce timer at the end like:

local touched = {}
local wTime = 1
script.Parent.Touched:connect (function(hit) --part is hit
	if hit and hit.Parent and hit.Parent:FindFirstChild:("Humanoid") and hit.Parent.canjump.Value and not touched[hit.Parent] then
		hit.Parent.Humanoid.Jump = true
		hit.Parent.canJump.Value = false	--Forgot to add value at the end
		touched[hit.Parent] = true
		wait(wTime)
		touched[hit.Parent] = false
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.