Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- -- Function to disable player collisions
- local function disableCollisions()
- -- Check if the character and humanoid exist
- if player.Character and player.Character:FindFirstChild("Humanoid") then
- -- Disable collisions for each part in the character
- for , part in pairs(player.Character:GetDescendants()) do
- if part:IsA("BasePart") then
- part.CanCollide = false
- end
- end
- end
- end
- -- Function to enable player collisions
- local function enableCollisions()
- -- Check if the character and humanoid exist
- if player.Character and player.Character:FindFirstChild("Humanoid") then
- -- Enable collisions for each part in the character
- for , part in pairs(player.Character:GetDescendants()) do
- if part:IsA("BasePart") then
- part.CanCollide = true
- end
- end
- end
- end
- -- Example: Disable collisions when 'E' key is pressed
- game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
- if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.E then
- disableCollisions()
- end
- end)
- -- Example: Enable collisions when 'R' key is pressed
- game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
- if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.R then
- enableCollisions()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment