Me and some friends are trying to make a boku no hero acadmia game i was wondering how to script press z to use and in 10 seconds you can walk in any walls than have a cooldown of 5 seconds before you may use. So to shorten that, by pressing z you can walk in walls like noclip for 10 seconds and then have a cooldown of 5 second
If you have FilteringEnabled, you could try this in a local script inside StarterGui, where you would have a part in workspace called Floor that the player could walk on (to prevent them from falling through the baseplate)
local debounce = true game:GetService("UserInputService").InputBegan:Connect(function(key,bool) if key.KeyCode == Enum.KeyCode.Z and debounce == true and bool == false then debounce = false local changedParts = {} for _,v in pairs(workspace:GetDescendants()) do if v:IsA("BasePart") and v.Name ~= "Floor" and v.CanCollide == true then v.CanCollide = false table.insert(changedParts,1,v) end end wait(10) for _,v in pairs(changedParts) do v.CanCollide = true end wait(5) debounce = true end end)
Other options could be to use collision filtering, but you would need remote events to do this.