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

How do you make a button function seperately?

Asked by 6 years ago
Edited 6 years ago

A material skin I made.

So I has the two following function

Mousebutton1down If the user decides to not let go and drags the mouse while pushing the button down out of the button.

MouseButton1Up Runs the function as well as run the material click

So I've been trying to make the button to detect if the user triggers the MouseButton1Up it won't fire the MouseButton1Down function so there won't be two circles in a button = better visual style.

Demo: https://gyazo.com/00c6bbd673dcfe8eb184fbf35e077a98

Suggestion: it is better to view the code in a window by clicking the view source button. I put most of the code in one line.

function CLICKUP(BTN)
    local idle = false;local mouse = game.Players.LocalPlayer:GetMouse();local RS = game:GetService("RunService").RenderStepped;local FX = Instance.new("ImageLabel",BTN);BTN.ClipsDescendants = true   
    FX.Size = UDim2.new(0, 0, 0, 0);FX.Position = UDim2.new(0, mouse.X - 0, 0, mouse.Y) - UDim2.new(0,BTN.AbsolutePosition.X, 0, BTN.AbsolutePosition.Y);
    FX.Image = 'http://www.roblox.com/asset/?id=200182847'; FX.BackgroundTransparency = 1;  FX.ZIndex = BTN.ZIndex; FX.Name = 'ClickAnim';  
    FX.ImageColor3 = Color3.fromRGB(209,209,209);
    FX.ImageColor3 = Color3.fromHSV(0, 0, 81);
    FX:TweenSizeAndPosition(UDim2.new(0, 500, 0, 500), FX.Position - UDim2.new(0, 250, 0, 250), 'Out', 'Sine', 1.1, true)
    for i=0, 1, .06 do
        FX.ImageTransparency = i
        RS:wait()
    end
    FX:Destroy()
end
function CLICKIDLE(BTN)
    local idle = true;local mouse = game.Players.LocalPlayer:GetMouse();local RS = game:GetService("RunService").RenderStepped;local FX = Instance.new("ImageLabel",BTN);BTN.ClipsDescendants = true; FX.BackgroundTransparency = 1
    FX.Position = UDim2.new(0, mouse.X - 0, 0, mouse.Y) - UDim2.new(0,BTN.AbsolutePosition.X, 0, BTN.AbsolutePosition.Y);   FX.Size = UDim2.new(0, 0, 0, 0); FX.Name = "IdleAnim";  FX.ImageColor3 = Color3.fromRGB(209,209,209);   FX.ImageColor3 = Color3.fromHSV(0, 0, 81); FX.ImageTransparency = .5; FX.Image = 'http://www.roblox.com/asset/?id=200182847';
    FX:TweenSizeAndPosition(UDim2.new(0, 900, 0, 900), FX.Position - UDim2.new(0, 250, 0, 250), 'Out', 'Sine', 1.5, true);
    wait(.3)
    for i=.5, 1, .03 do
        FX.ImageTransparency = i
        RS:wait()
        RS:wait()
    end
    FX:Destroy()
end
script.Parent.MouseButton1Up:connect(function()
    CLICKUP(script.Parent)
end)

script.Parent.MouseButton1Down:connect(function()
    CLICKIDLE(script.Parent)
end)
0
can't you just use MouseButton1Click instead of Up and Down? justoboy13 153 — 6y

Answer this question