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 » Scripters
Home Search
 

Re: CFrame

Previous Thread :: Next Thread 
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
24 Mar 2015 04:42 PM
I have a door that works with BodyGyro. The only problem is the door sticks out of its hinges if it's not at a certain rotation. I had this fixed but somehow lost the script and now I can't redo it even though I swear I've made the exact same adjustments. Can anyone help? It's driving me crazy!!!

door = script.Parent.Parent.Door
dist = 10
door.BodyGyro.cframe = CFrame.new(door.Position) * CFrame.Angles(0, math.pi, 0)

function clicked()
local p = game.Players:GetChildren()
for i = 1, #p do
if (p[i].Name == script.Parent.Parent.Parent.OwnerName.Value) then
if (p[i].Character.Torso.Position - script.Parent.Position).magnitude < dist then
print("MakeScript Done...") -- this is just an example
door.BodyGyro.maxTorque = Vector3.new(100,100,100)
door.BodyGyro.P = 5
wait(3)
door.BodyGyro.maxTorque = Vector3.new(5000, 5000, 5000)
door.BodyGyro.P = 50
end
end
end
end

script.Parent.ClickDetector.MouseClick:connect(clicked)
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
24 Mar 2015 05:10 PM
You should be using a Motor instead. It's much more consistent.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
24 Mar 2015 05:28 PM
I've no idea how to work a motor
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
24 Mar 2015 06:37 PM
Bump
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
24 Mar 2015 06:41 PM
What exactly does the door do? Prevent being opened? Open itself? Close itself? Details pl0x.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
24 Mar 2015 06:46 PM
Sorry, it prevents people from opening it until it's clicked. Three seconds after this it shuts again.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
24 Mar 2015 07:30 PM
Bump
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
24 Mar 2015 08:30 PM
door.BodyGyro.maxTorque = Vector3.new(0,0,0)
door.BodyGyro.P = 5
wait(3)
door.BodyGyro.maxTorque = Vector3.new(5000, 5000, 5000)
door.BodyGyro.P = 50

Also, you should have a line at the beginning like this:

local Original_Position = door.BodyGyro.cframe

so you can call it later in the script to shut the door back to how it originally was.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
24 Mar 2015 08:37 PM
Nope. The problem is that the door sticks out before it's even touched.
Here it is: http://www.roblox.com/Scripting-tests-place?id=69926162
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
24 Mar 2015 08:43 PM
Basically, the door's default position ISN'T closed, where it's supposed to be.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 10:02 AM
Bump
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 11:30 AM
Bump
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
25 Mar 2015 11:37 AM
door = script.Parent.Parent.Door
dist = 10
door.BodyGyro.cframe = CFrame.new(door.Position)
local o_cframe = door.CFrame

function clicked()
local p = game.Players:GetChildren()
for i = 1, #p do
if (p[i].Name == script.Parent.Parent.Parent.OwnerName.Value) then
if (p[i].Character.Torso.Position - script.Parent.Position).magnitude < dist then
print("MakeScript Done...") -- this is just an example
door.BodyGyro.maxTorque = Vector3.new(5000,5000,5000)
door.BodyGyro.P = 500
door.BodyGyro.cframe = o_cframe*CFrame.Angles(0,math.rad(90),0)
wait(3)
door.BodyGyro.maxTorque = Vector3.new(5000, 5000, 5000)
door.BodyGyro.P = 500
door.BodyGyro.cframe = o_cframe
end
end
end
end

Tell me if this works.
Also, please learn how CFrame and BodyGyros work before trying to do something like this. My advice? Go into Play Mode with a place containing only a spawn location, base plate, and a test block with a BodyGyro in it. Use the command line to change the BodyGyro.cframe and see what happens.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 11:40 AM
Nope, still the same problem.
I am learning with this script, no? ;)
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
25 Mar 2015 11:42 AM
What exactly does my bit of code do? It definitely should not give you the same problem you are facing... I currently cannot test it myself so I'm not sure what exactly it does. I'm just really confident that it generally keeps the door close until opened, and when opened, opens 90 degrees, then closes.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 11:52 AM
I'm afraid it does do the same thing. It's 'closed' state is at a 90 degree angle to the door.
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
25 Mar 2015 12:40 PM
The door should be in the close position to begin with.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 12:43 PM
Yes, I have it in a closed position in Studio, but it springs open when played.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 02:31 PM
Bump
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
25 Mar 2015 02:43 PM
Something like this can get complicated because there are so many things that can be causing this to fail. It's not really anything anyone here is willing to delve into because it would take too much time and energy to walk you through the steps and errors one by one.

Post the model, I will fix it for you when I have the time, and I will tell you exactly what I did.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 02:54 PM
http://www.roblox.com/My/Item.aspx?ID=230209348

Danke, friend.
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
25 Mar 2015 03:34 PM
http://www.roblox.com/Here-you-go-item?id=230223471

I made changes and notes, look at em' pl0x.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 04:10 PM
Danke.
I didn't want the door to open automatically but I can change that :)
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
25 Mar 2015 04:12 PM
Ah. Ok. Well, hope I helped.
Report Abuse
bladeclone is not online. bladeclone
Joined: 06 Jul 2009
Total Posts: 2179
25 Mar 2015 04:42 PM
I've tried to use your more efficient script with something else but it won't work at all.


one = script.Parent.A
two = script.Parent.B
three = script.Parent.C
four = script.Parent.D
five = script.Parent.E
deployed = script.Parent.Deployed.Value

local owner = script.Parent.Parent.Parent.OwnerName --Declare here so we don't need to say all those .Parent's later on

function clicked(player)
if player.Name ~= owner.Value then print("You aren't my owner! GET AWAYYYY!!!") return end --If owner didn't click it returns
if (deployed == false) then
one.Transparency = 0
wait(0.1)
two.Transparency = 0
wait(0.1)
three.Transparency = 0
wait(0.1)
four.Transparency = 0
wait(0.1)
five.Transparency = 0
deployed = true
else if (deployed == true) then
five.Transparency = 1
wait(0.1)
four.Transparency = 1
wait(0.1)
three.Transparency = 1
wait(0.1)
two.Transparency = 1
wait(0.1)
one.Transparency = 1
deployed = false
end


local stuff = script.Parent:GetChildren() --Pleaseeee never put so many scripts for little things like that in so many parts
for i = 1, #stuff do if stuff[i]:FindFirstChild("ClickDetector") then
stuff[i].ClickDetector.MouseClick:connect(clicked) --It gets messy really quick, just do something like this
end
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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