Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make my collision script for ladders mobile compatible?

Asked by 8 years ago

Hello, I'm making a 2D game on Roblox. I have it so when you press W on the keyboard the collisions for the trusses are turned on, however, this only works on PCs or other keyboard enabled devices, can any one help me with this. Here is my code, I'm new to scripting so it'll probably look a bit messy.

local L = game.workspace.T1
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:connect(function(inputObject)
    if inputObject.KeyCode == Enum.KeyCode.W and L.CanCollide == false then 
            L.CanCollide = true
        end
    end)
userInputService.InputBegan:connect(function(inputObject)
     if inputObject.KeyCode == Enum.KeyCode.Space and L.CanCollide == true then
            L.CanCollide = false

    end
end)
userInputService.InputBegan:connect(function(inputObject)
     if inputObject.KeyCode == Enum.KeyCode.Space and inputObject.KeyCode == Enum.KeyCode.W  then
            L.CanCollide = true

    end
end)
0
why do you make people press W to turn on collision? you could just leave it on the whole time lol Perci1 4988 — 8y
0
Because, when people move back and forth infront of the ladder they climb up it, I want it so you can only climb the ladder if you're actually facing towards it, like in an actual 2D game herobrine5658 5 — 8y

Answer this question