|
| 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 |
|
|
|
| 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 |
|
|
|
| 26 Jun 2013 10:48 PM |
| Trying to make the camera not lag when the player moves, using a top down camera. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 26 Jun 2013 10:52 PM |
| I might be able to make it work, any other ideas? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 26 Jun 2013 11:34 PM |
Try this in Studio:
print(Workspace:FindFirstChild("Pie").Parent) |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 10 Aug 2008 |
| Total Posts: 7944 |
|
|
| 26 Jun 2013 11:37 PM |
| Waitforchild. Would be better. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 26 Jun 2013 11:37 PM |
Ignore that lol
~ The ATR Fishie ~ |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|