darkhenryJoin Date: 2010-05-08 Post Count: 85 |
Hi, hope you're doing well on this fine day.
(FilteringEnabled)
here's my script, just a simple test.
local plr = game.Players.LocalPlayer
local main_gui = plr:WaitForChild("PlayerGui"):WaitForChild("test")
local frame = main_gui:WaitForChild("Frame")
frame.BackgroundTransparency = 1
Mouse = plr:GetMouse()
Mouse.KeyDown:Connect(function(Key)
Key = Key:lower()
if Key == "g" then
frame.BackgroundTransparency = 0
end
end)
I was wondering how I would use the same button "g" to then turn the frame's BackgroundTransparency to 1 again. I've searched the Object browser on Mouse and I didn't find anything on keys.. |
|
little5Join Date: 2008-03-02 Post Count: 178 |
You could do frame.BackgroundTransparency = not frame.BackgroundTransparency if frame.BackgroundTransparency == 1 |
|
darkhenryJoin Date: 2010-05-08 Post Count: 85 |
It doesn't just pertain to transparency though.
I was just wondering if you could press "g" twice and perform different functions.
Thanks for your reply.
:) |
|
darkhenryJoin Date: 2010-05-08 Post Count: 85 |
bump |
|
|
I think what little was trying to say is you can change this line
frame.BackgroundTransparency = 0
to this
frame.BackgroundTransparency = ((frame.BackgroundTransparency == 1) and 0 or 1)
to make it a toggle |
|
AliicsJoin Date: 2014-09-29 Post Count: 471 |
ternary operators yo |
|
|
ternary operators are my bread and butter |
|
|
darkhenryJoin Date: 2010-05-08 Post Count: 85 |
Thanks to both of you :)
helped me out alot |
|
AliicsJoin Date: 2014-09-29 Post Count: 471 |
Well that's an interesting bit of code. I'd highly suggest commenting it. |
|
|
|
here's my script, just a simple test.
local plr = game.Players.LocalPlayer
local main_gui = plr:WaitForChild("PlayerGui"):WaitForChild("test")
local frame = main_gui:WaitForChild("Frame")
frame.BackgroundTransparency = 1
local UIS = Game:GetService("UserInputService")
UIS.InputBegan:Connect(function(key, gpe)
if gpe then return end
if key.KeyCode == Enum.KeyCode.G then
frame.BackgroundTransparency = frame.BackgroundTransparency == 1 and 0 or 1
end
end)
sorry for tabbing did this in post editor thingy |
|
|
wouldn't use keydown
local uis = game:GetService("UserInputService")
uis.InputBegan:connect(function(input, gameProcessed)
if input.KeyType == Enum.KeyType.G then
frame.BackgroundTransparency = 0
end
end)
|
|
|
KeyCode* use the person's code above me pl0x |
|
|
is that baby carlos lol?
nice |
|
|
funny that Im also in that post @Jarod |
|