I'm feeling generous. Go crazy, kid:
####! Not R15 compatible !
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local ClipToggleKey = Enum.KeyCode.N
local ClipEnabled = true
local UnClipConnection;
local function HandleClip(InputObject, GameProcessedInput)
if (GameProcessedInput) then return end
if (InputObject.KeyCode == ClipToggleKey) then
ClipEnabled = (not ClipEnabled)
if (not ClipEnabled) then
local Character = Player.Character or Player.CharacterAdded:Wait()
UnClipConnection = RunService.Stepped:Connect(function()
Character.Head.CanCollide = false
Character.Torso.CanCollide = false
end)
else
UnClipConnection:Disconnect()
end
end
end
UserInputService.InputBegan:Connect(HandleClip)
#####RESOURCES:
2 comments
Are you meaning inside of the script or the script itself?
It would be better if you could just put this code in a function and then call that function via UserInputService. You can read more about it here: https://www.youtube.com/watch?v=4z1HVwe0sLE