Script not detecting mouse clicks

Im trying to make a forsaken-like game, ive made mobile controls and now copying those simple scripts over for this script and tweaking it to work better with PC .

Problem is that its not detecting when the mouse is clicked, help please

wait(0.1)
local Animator = workspace:FindFirstChild(script.Parent.Parent.Parent.Parent.Parent.Name):FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local Cooldown = script.Parent.Parent.Cooldown
local Animation  = script.Parent.Parent.Animation

game.UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean) 
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if Animator then
			if Cooldown.Value == 0 then
				wait(0)
				Cooldown.Value = 2
				local anim = Animator:LoadAnimation(Animation)
				anim:Play()
				local anim = Animator:LoadAnimation(Animation)
				anim:Play()
				Animator.Parent.Parent:FindFirstChild("KickboxScript").Enabled = true
				wait(0.1)
				Animator.Parent.Parent:FindFirstChild("KickboxScript").Enabled = false
			else
				print("Failed2")
			end


		else
			print("Failed")
		end
	end	
	
end)
1 Like

Are you sure it’s not running the animation?
You only print when it fails. Try putting a print statement where the anim logic is.

Ill try that
(characters so i can post)

Nope, it doesnt work, idk whats happening

I’ve tested it on my own end, and nothing is wrong with your snippet. You’ll have to dig deeper. Is this on a localscript?

Are you sure you are pressing mousebutton1, which is the shoot button?

No, it is not runnin on a local script so it can do actual damage

Yes, i am pressin mousebutton1 aka left click.

UserInputService is not going to work on a server script, what you should do is have the input and animation in a local script and connect it to a server script with a remote event when you want it to do damage

3 Likes

Oh, ok. Thank you!!!

(letters for posting)

TSYM!!! IT WORKS!!! didnt know you had to do it in a localscript

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