Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to have different functions for quick click, mouse hold, and mouse release?

I can only do the mouse hold and mouse release by using mouse.Button1Down and Mouse.Button1Up.

1 comment

0

Use UserInputService, GetMouse() isn't really that usefull for that!

1 answer

local input = game:GetService("UserInputService")
local plr = game.Player.LocalPlayer
input.InputBegin:Connect(function() -- everything u type or click will be recorded 
	if input.UserInputType == Enum.UserInputType.MouseButton1 and plr.Character ~= nil then -- if mousebutton1 is clicked aka left mouse button, and checks if plr.Character is a thing
		local anim = instance.new("animation") -- makes animation
		anim.Animationid = "http://www.roblox.com/asset/?id=Animation here" -- specify animation id
		local track = plr.Character.Humanoid:LoadAnimation(anim) -- loads the animation
		track:Play() -- plays animation
		-- ur code here
	end
end)

input.InputEnded:Connect(function() -- everything u type or click will be recorded this will activate when u release ur key
	if input.UserInputType == Enum.UserInputType.MouseButton1 then -- when u released ur click
		-- ur code here
	end
end)


Not sure if this is what u wanted but i hope it helps here is some more info = https://developer.roblox.com/en-us/api-reference/class/UserInputService

4 comments

0

Or you can add input.changed:Connect(function), inside InputBegan instead of using InputEnded

0

I already know this. But what I want to play a specific animation when mouse is click quickly.

0

Oh

0

I edited it

This discussion is preserved as it was. New answers, comments, and votes are closed.