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?
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)