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

Button doesn't work?

Asked by 8 years ago

It wont work lol. Doesn't even look like it's being click. All I want is so when you hold the left mouse button down over it, it brings up a GUI but when you lift the left mouse button or uh, unlick it idk the word for letting go of it lol, the GUI disappears. Doesn't even look like i'm clicking the button though like it doesn't react. No GUI comes up and the button itself doesn't like, you know where it goes white and all to let you know you have clicked it. Anyways here is the code:

local version = script.Parent
local HUD = game.Players.LocalPlayer.PlayerGui.HUD
local clone = game.ReplicatedStorage.VersionMore:Clone()

function opengui(onClicked)
    version.Button1Down.clone(HUD.Character)
    version.Button1Up.HUD.Character.VersionMore:Destroy()
end


What's wrong how is it fixed? Anyhelp is appreciated :)

2 answers

Log in to vote
0
Answered by 8 years ago

Your events are inside of an uncalled function, so they do nothing unless the function is called. Instead have them outside of it.

Also Button1Down,Button1Up I believe are mouse events, not for 2D GUI objects. Instead you should use MouseButton1Down, MouseButton1Up.

version.MouseButton1Down:connect(function()
    HUD.Character:Clone();
    version.MouseButton1Up:connect(function()
        HUD.Character.VersionMore:Destroy();
    end)
end)
Ad
Log in to vote
0
Answered by 8 years ago

The above is correct but I recommending to always using a, :WaitForChild() command because due to ROBLOX clients being slow etc. I do hope this answer your question.

local player = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local version = script.Parent

local HUD = player.HUD
local clone = game.ReplicatedStorage.VersionMore:Clone()

version.MouseButton1Down:connect(function()
HUD.Character:Clone();

version.MouseButton1Up:connect(function()
 HUD.Character.VersionMore:Destroy();


    end)
end)

Answer this question