Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

0
Use UserInputService, GetMouse() isn't really that usefull for that! LikeToScript 108 — 4y

Closed as Not Constructive by User#29913, youtubemasterWOW, and Leamir

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
2
Answered by
IcyMizu 122
4 years ago
Edited 4 years ago
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

0
Or you can add input.changed:Connect(function), inside InputBegan instead of using InputEnded LikeToScript 108 — 4y
0
I already know this. But what I want to play a specific animation when mouse is click quickly. Inciney 7 — 4y
0
Oh IcyMizu 122 — 4y
0
I edited it IcyMizu 122 — 4y
Ad