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 » Game Design
Home Search
 

Re: Anchor/Unanchor on click?

Previous Thread :: Next Thread 
ClockChimesThirteen is not online. ClockChimesThirteen
Joined: 29 Dec 2012
Total Posts: 571
11 Sep 2015 10:31 PM
Hello! I'm, basically, trying to get a ceiling fan to turn "on" and "off" when clicking a separate brick. I'm trying to achieve this by anchoring and unanchoring the motor and blades attached to the motor, but I've been unable to get the brick I'm using as the "switch" to work. My script is, as follows:

local brick = script.Parent;

local fan = script.Parent.Parent.Parent.Fan.CeilingFan.Part.Anchored;

brick.ClickDetector.MouseClick:connect(function()
if fan.Anchored == true then
fan.Anchored = false
elseif fan.Anchored == false then
fan.Anchored = true
end
end)

Everything is grouped properly and I have checked, double-checked, and re-checked that all of my paths are correct.

Alternatively, is there a better way to achieve this? I'm not sure how to make a brick spin continuously with a script. I also thought of using separate parts and making them alternate between visible and invisible to give the appearance of turning, but I'm not sure if it would be possible to create a continuing loop with a script when the fan is turned "on". and then ending the script when the fan is turned "off".

Any help is appreciated. Thank you!
Report Abuse
awsomecoolhacker is not online. awsomecoolhacker
Joined: 13 Jun 2010
Total Posts: 158
11 Sep 2015 10:58 PM
You put local fan = script.Parent.Parent.Parent.Fan.CeilingFan.Part.Anchored; which gives you a bool value as it is a property

You meant to do this:

local fan = script.Parent.Parent.Parent.Fan.CeilingFan.Part // Remove ".Anchored"
Report Abuse
ClockChimesThirteen is not online. ClockChimesThirteen
Joined: 29 Dec 2012
Total Posts: 571
11 Sep 2015 11:06 PM
Thank you. I fixed that, but the fan is still unresponsive when I test the switch. My script is now:

local brick = script.Parent;

local fan = script.Parent.Parent.Parent.Fan.CeilingFan.Part;

brick.ClickDetector.MouseClick:connect(function()
if fan.Anchored == true then
fan.Anchored = false
elseif fan.Anchored == false then
fan.Anchored = true
end
end)
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
11 Sep 2015 11:08 PM
local brick = script.Parent;

local fan = brick.Parent.Parent.Fan.CeilingFan.Part;

brick.ClickDetector.MouseClick:connect(function()
fan.Anchored = not fan.Anchored
end)
Report Abuse
ClockChimesThirteen is not online. ClockChimesThirteen
Joined: 29 Dec 2012
Total Posts: 571
11 Sep 2015 11:13 PM
Thank you. I tried your script, but the outcome is the same. I'm just not sure why this isn't working, but then, I'm only a beginner.
Report Abuse
alphaboy299 is not online. alphaboy299
Joined: 15 Jun 2013
Total Posts: 1496
11 Sep 2015 11:15 PM
I'm not really sure about this but when you say "Parent.Parent.Fan" it may have mistook it for a property of the parent therefore you could try this-

local brick = script.Parent;

local fan = script.Parent.Parent.Parent:FindFirstChild("Fan").CeilingFan.Part;

brick.ClickDetector.MouseClick:connect(function()
if fan.Anchored == true then
fan.Anchored = false
elseif fan.Anchored == false then
fan.Anchored = true
end
end)
Report Abuse
ClockChimesThirteen is not online. ClockChimesThirteen
Joined: 29 Dec 2012
Total Posts: 571
11 Sep 2015 11:18 PM
Unfortunately that didn't work, either, but thank you. This might be more trouble than it's worth at this point!
Report Abuse
ClockChimesThirteen is not online. ClockChimesThirteen
Joined: 29 Dec 2012
Total Posts: 571
11 Sep 2015 11:32 PM
Well, I feel silly now. I accidentally welded an anchored part to the parts that were meant to be unanchored. My apologies! Thank you all, again, for all of your help. It's working properly now.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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