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: Onclick

Previous Thread :: Next Thread 
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 07:57 PM
Im creating a script where when someone click on a certain part, that part will move.

Heres my current script

while true do wait()
if findIfClose(game.Workspace) then
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(0.2,0,0)
end
wait(2)
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(-0.2,0,0)
end
wait(0.5)
end
end
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 08:03 PM
Edited part

onclick() do
if findIfClose(game.Workspace) then
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(0.2,0,0)
end
wait(2)
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(-0.2,0,0)
end
wait(0.5)
end
end
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 08:15 PM
I did this script I created and it still doesn't work.

function onClicked()
if findIfClose(game.Workspace) then
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(0.2,0,0)
end
wait(2)
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(-0.2,0,0)
end
wait(0.5)
end
end



script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 08:20 PM
Okay, now I tried it with that shows all the parts separate.


function onClicked()
if findIfClose(game.Workspace) then
for i=1,40 do wait()
script.Parent.Door.CFrame = script.Parent.Door.CFrame + Vector3.new(0.2,0,0)
script.Parent.Handle.CFrame = script.Parent.Handle.CFrame + Vector3.new(0.2,0,0)
script.Parent.Lock.CFrame = script.Parent.Lock.CFrame + Vector3.new(0.2,0,0)
end
wait(2)
for i=1,40 do wait()
script.Parent.Door.CFrame = script.Parent.Door.CFrame + Vector3.new(-0.2,0,0)
script.Parent.Handle.CFrame = script.Parent.Handle.CFrame + Vector3.new(-0.2,0,0)
script.Parent.Lock.CFrame = script.Parent.Lock.CFrame + Vector3.new(-0.2,0,0)
end
wait(0.5)
end
end



script.Parent.ClickDetector.MouseClick:connect(onClicked)
Report Abuse
blox6137 is not online. blox6137
Joined: 23 Nov 2008
Total Posts: 1109
15 Jul 2014 08:23 PM
local what = script.parent

local click = Instance.new("ClickDetector")
click.Parent = what


click.MouseClick:connect(function()
if findIfClose(game.Workspace) then
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(0.2,0,0)
end
wait(2)
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(-0.2,0,0)
end
wait(0.5)
end
end
end)

This 'fix' may work.
Sorry if it doesn't... Because I didn't read through your code- sorry :/
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 08:28 PM
It didn't move a stud..
Report Abuse
blox6137 is not online. blox6137
Joined: 23 Nov 2008
Total Posts: 1109
15 Jul 2014 08:30 PM
this may work,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local move = script.Parent

local click = Instance.new("ClickDetector")
click.Parent = move

click.MouseClick:connect(function()
if findIfClose(game.Workspace) then
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(0.2,0,0)
end
wait(2)
for i=1,40 do wait()
script.Parent.DoorParts.CFrame = script.Parent.DoorParts.CFrame + Vector3.new(-0.2,0,0)
end
wait(0.5)
end
end)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
15 Jul 2014 08:30 PM
script.parent is not script.Parent

capitilization
Report Abuse
blox6137 is not online. blox6137
Joined: 23 Nov 2008
Total Posts: 1109
15 Jul 2014 08:30 PM
I can't really test the script because I don't have the whole deal. I don't have "DoorParts" in my workspace. Maybe try my new code.
Report Abuse
blox6137 is not online. blox6137
Joined: 23 Nov 2008
Total Posts: 1109
15 Jul 2014 08:31 PM
Yes, I fixed that, as you can see :P

And the first one was fixing your onClick function or whatev. You did it weird :P
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 08:34 PM
Im confused
Report Abuse
blox6137 is not online. blox6137
Joined: 23 Nov 2008
Total Posts: 1109
15 Jul 2014 08:34 PM
Me too.
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 08:39 PM
What script is the correct one?
Report Abuse
TheNextEvolution is not online. TheNextEvolution
Joined: 08 Apr 2010
Total Posts: 1624
15 Jul 2014 08:41 PM
lolol if findIfClose(game.Workspace) then wtf is findIfClose
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 08:43 PM
It finds if the door is closed.
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
15 Jul 2014 09:45 PM
bump
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
16 Jul 2014 02:39 AM
bump

Im pretty sure that my script was almost right, but it still no work. :(
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
16 Jul 2014 03:02 AM
Okay, so I finally got it where when you click it, it will open. But it will not take the other two parts with it. I tried putting the two parts inside the main part. Still nothing. How would I get the script to notice that the other two parts are a parent with the main parent?
Report Abuse
CyborgDonut is not online. CyborgDonut
Joined: 06 Aug 2013
Total Posts: 733
16 Jul 2014 03:16 AM
Never mind, I soon found out that I could weld them together. Thanks for the help you guys gave me. Thread closed. xD
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