Disabling Click Detection

How could i disable the player from being able to click like in the code shown below

input.UserInputType == Enum.UserInputType.MouseButton1

using the code here

--// Services
local Players = game:GetService("Players")
local ContentProvider = game:GetService("ContentProvider")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--// AnimationFolder
local anims = ReplicatedStorage:WaitForChild("Animations")

--// Player
local Plr = Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Hum = Char:WaitForChild("Humanoid")

Hum.WalkSpeed = 0
Hum.JumpPower = 0

for i, v in pairs(anims:GetDescendants()) do
	if v:IsA("Animation") then
		ContentProvider:PreloadAsync({v})
	end
end
warn("Finished Preloading")

Hum.WalkSpeed = 16
Hum.JumpPower = 50

What do you mean by not be able to click? Do you want so that when the player clicks on their mouse or taps the screen that any associated events not fire? If so here is a script

local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

game:GetService("RunService").Heartbeat:Wait()

if character then
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then

		ContextActionService:BindAction("DisableClick", function() 
			return Enum.ContextActionResult.Sink 
		end, false, Enum.UserInputType.MouseButton1, Enum.UserInputType.Gamepad1, Enum.UserInputType.Touch)
	end
end

to make the player be able to click again do

ContextActionService:UnbindAction("DisableClick")
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.