generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Click & Hold script?

Previous Thread :: Next Thread 
Robloxmannnnnnnn is not online. Robloxmannnnnnnn
Joined: 21 Feb 2009
Total Posts: 789
16 Nov 2014 12:04 AM
You click the part, and you hold it down to make the Transparency 1. If you let go, the brick will have Transparency 0.

Basically, I have a simple click detector script that you click once, transparency 1, click again, transparency 0. Is there any way to make it so if you click & hold, transparency 1, let go, transparency 0.

function onClicked(playerWhoClicked)
if game.Workspace.Lights.rvl.L.Enabled == false then
game.Workspace.rvc.Transparency = 1
game.Workspace.Lights.rvl.L.Enabled = true
else
game.Workspace.rvc.Transparency = 0
game.Workspace.Lights.rvl.L.Enabled = false
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

The script works, but I don't know how to make it click & hold.
Report Abuse
Minecraftrulz94 is not online. Minecraftrulz94
Joined: 22 Feb 2014
Total Posts: 233
16 Nov 2014 12:13 AM
function onUp()
game.Workspace.rvc.Transparency = 0
game.Workspace.Lights.rvl.L.Enabled = false
end

function onClicked()
game.Workspace.rvc.Transparency = 1
game.Workspace.Lights.rvl.L.Enabled = true
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
script.Parent.ClickDetector.mouse.Button1Up:connect(onUp)

Tell me if that works, thanks :)
Report Abuse
Minecraftrulz94 is not online. Minecraftrulz94
Joined: 22 Feb 2014
Total Posts: 233
16 Nov 2014 12:16 AM
If that doesn't work, try:

function onUp()
game.Workspace.rvc.Transparency = 0
game.Workspace.Lights.rvl.L.Enabled = false
end

function onClicked()
game.Workspace.rvc.Transparency = 1
game.Workspace.Lights.rvl.L.Enabled = true
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
script.Parent.ClickDetector.MouseUp:connect(onUp)
Report Abuse
Robloxmannnnnnnn is not online. Robloxmannnnnnnn
Joined: 21 Feb 2009
Total Posts: 789
16 Nov 2014 12:25 AM
"MouseUp is not a valid member of ClickDetector"
Report Abuse
thermonuklear is not online. thermonuklear
Joined: 19 Oct 2014
Total Posts: 484
16 Nov 2014 01:29 AM
Change MouseClick to MouseButton1Down.
Change MouseUp to MouseButton1Up.
Report Abuse
Robloxmannnnnnnn is not online. Robloxmannnnnnnn
Joined: 21 Feb 2009
Total Posts: 789
16 Nov 2014 03:17 PM
MouseButton1Down is not a valid member of ClickDetector.
Report Abuse
Robloxmannnnnnnn is not online. Robloxmannnnnnnn
Joined: 21 Feb 2009
Total Posts: 789
16 Nov 2014 03:34 PM
b1
Report Abuse
Robloxmannnnnnnn is not online. Robloxmannnnnnnn
Joined: 21 Feb 2009
Total Posts: 789
16 Nov 2014 04:21 PM
b2
Report Abuse
Robloxmannnnnnnn is not online. Robloxmannnnnnnn
Joined: 21 Feb 2009
Total Posts: 789
16 Nov 2014 04:36 PM
b3
Report Abuse
Robloxmannnnnnnn is not online. Robloxmannnnnnnn
Joined: 21 Feb 2009
Total Posts: 789
16 Nov 2014 05:06 PM
b4...
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
16 Nov 2014 05:15 PM
ClickDetectors don't have a release event I think
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
16 Nov 2014 05:22 PM
local script in startergui

local targeting = "" --Name of the brick in workspace
local mouse = game.Players.LocalPlayer:GetMouse()
local down = false

mouse.Button1Down:connect(function()
down = true
end)

mouse.Button1Up:connect(function()
down = false
end)

while true do
wait()
if down == true then
if mouse.Target == game.Workspace:WaitForChild(targeting) then
for i = 0,1,.1 do
mouse.Target.Transparency = i
wait()
end
end
elseif down == false and mouse.Target == game.Workspace:WaitForChild(targeting) then
game.Workspace:WaitForChild(targeting).Transparency = 0
end
end


Didn't write in studio. The targeting variable is the brick in Workspace.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
17 Nov 2014 12:28 AM
It's not a Gui, it's a brick e.e, and it could be more efficient without dat loop.
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
17 Nov 2014 10:20 AM
Happy, this functions correctly. But goes in the StarterGui. Obviously I'm more advanced then chu c:
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image