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: .Changed not working when position is changed?

Previous Thread :: Next Thread 
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 10:45 PM
I have the following code:

character.Head.Changed:connect(function()
FollowCamera()
print("head moved")
end)

but it is not firing even though my Head position is changing. If I change the transparency or something, it works fine. Why?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
26 Jun 2013 10:47 PM
Yes, I've had similar problems, trying to track the torso's movement with .Changed. Anything specific you're trying to do?
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 10:48 PM
Trying to make the camera not lag when the player moves, using a top down camera.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
26 Jun 2013 10:49 PM
You can try the .Running event for the Humanoid.

http://wiki.roblox.com/index.php/Running_(Event)
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 10:52 PM
I might be able to make it work, any other ideas?
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 11:06 PM
ERMAHGERD, it worked!

Here's the code if anyone wants it!

character.Humanoid.Running:connect(function(property)
local Stepped = Game:GetService("RunService").Stepped
while property > 0 do
FollowCamera()
Stepped:wait()
end
end)
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 11:09 PM
Wait no, that code sucks, here's the actual one:

character.Humanoid.Running:connect(function(speed)
local Stepped = Game:GetService("RunService").Stepped
while character.Head.Velocity ~= Vector3.new(0,0,0) do
FollowCamera()
Stepped:wait()
end
end)
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:19 PM
character:FindFirstChild("Head").Parent.Changed:connect(function()

Perhaps that would work better? FindFirstChild is for if it doesn't exist, you'd have errors.

~ The ATR Fishie ~
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
26 Jun 2013 11:27 PM
@lord

Doing it that way wouldn't make a difference; it would still error if Head didn't exist.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:33 PM
No it wouldn't. I'm getting the vibe that you wouldn't take my word for it, so I can let you see some of my code or you can just try it for yourself.

~ The ATR Fishie ~
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
26 Jun 2013 11:34 PM
Try this in Studio:

    print(Workspace:FindFirstChild("Pie").Parent)
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:36 PM
@OP
what you want is this
character:FindFirstChild("Head").Position.Changed:connect(function()

I assumed you were checking to see if it existed with this line:
character.Head.Changed:connect(function()


~ The ATR Fishie ~
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:37 PM
@Knight
Nil doesn't have a parent..?

~ The ATR Fishie ~
Report Abuse
bohdan77 is not online. bohdan77
Joined: 10 Aug 2008
Total Posts: 7944
26 Jun 2013 11:37 PM
Waitforchild. Would be better.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:37 PM
Ignore that lol

~ The ATR Fishie ~
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
26 Jun 2013 11:38 PM
Like I said, it would error if the Head didn't exist like the original. Plus, you can't use the .Changed event on properties anyways. He also already fixed it so...
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 11:38 PM
nono, the .Changed wouldn't fire if only the Position and Velocity changed. However, it fired if I changed another property such as Transparency or Friction.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:41 PM
It wouldn't fire on a Vector3?

And Knight, what fixed my code was this:
if Char:FindFirstChild("Ears") then
Char.Ears:Destroy()
end

without FindFirstChild it errors.

~ The ATR Fishie ~
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
26 Jun 2013 11:42 PM
Yes, but with your example, it's like doing this:

    Char:FindFirstChild("Ears"):Destroy()

Which would error should Ears not exist.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:46 PM
Yes, I know. I only added on the ".Parent" once I had though I understood what he was trying to do. All that needed to be changed was adding an if statement before the function checking to see if Head existed.

I was only commenting to show him each way of doing something.

~ The ATR Fishie ~
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
26 Jun 2013 11:49 PM
Yeah. . . And if you did that, you wouldn't need to use FindFirstChild on the actual connection line. . .
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 11:50 PM
"I was only commenting to show him each way of doing something."

I know how to script ಠ_ಠ
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
26 Jun 2013 11:55 PM
@Knight
On the if line, like I said. Everyone makes mistakes :p

@Yo
I don't know what you know and what you don't know (used "know" three times lol).

~ The ATR Fishie ~
Report Abuse
yomamadude6 is not online. yomamadude6
Joined: 21 Nov 2009
Total Posts: 2151
26 Jun 2013 11:58 PM
Fair enough.
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