werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 27 Feb 2013 01:14 PM |
I have a footprint script I made, and it works almost perfectly. When you step on a brick, it makes footprints appear below your character. But there's a few problems. If there's more than one person in the game, and one person steps on the brick, it gives the footprints to a random person. Another problem is when someone has footprints, the people who don't have footprints can never get them. The last problem is that when you jump the footprints float in the air. How could I fix these when I have this code?
Code:
function footprints()
wait(1) ----I'm thinking it has something to do with these lines for o, b in pairs(game.Players:GetChildren()) do if b.Character:findFirstChild("Left Leg") then leftleg = b.Character:findFirstChild("Left Leg")
if b.Character:findFirstChild("Right Leg") then rightleg = b.Character:findFirstChild("Right Leg")
model = game.Lighting.FootPrint1 _G.footprint = model:clone() _G.footprint2 = model:clone() model:remove() _G.footprint.Parent = game.Workspace _G.footprint.Name = "FootPrint1"
_G.footprint2.Parent = game.Workspace _G.footprint2.Name = "FootPrint2"
while true do wait(0.2) _G.footprint.CFrame = leftleg.CFrame - Vector3.new(0, 1, 0) _G.footprint2.CFrame = rightleg.CFrame - Vector3.new(0, 1, 0) end
end
end end
end
function onTouched(hit) footprints() end
script.Parent.Touched:connect(onTouched)
I commented on where I think the problem is. What can I do to fix the problems? |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 27 Feb 2013 01:29 PM |
| I don't think the first function has a connection line. |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 27 Feb 2013 01:41 PM |
I looked on the Wiki, and all you need is an 'end' if you made your own function. If it's a built-in Roblox function, then you would need a connection line.
This is an example from the Wiki:
function twoPlusTwo() -- Function name x = 2 + 2 -- Variable print(x) -- Print variable's value end -- End twoPlusTwo() -- This is how you call a function. Once called it will run your block of code from before. |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 27 Feb 2013 03:45 PM |
| Anyone? This is important to me :c |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 27 Feb 2013 06:09 PM |
| Okay. I fixed it. But I still need to know how to make it stay on the ground when you jump. How would I do that? |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 28 Feb 2013 05:12 PM |
| I tried putting a Jump function in there, but it didn't work since I can't have functions inside functions. Is there any other way to do it? |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2013 05:15 PM |
You can have functions inside of functions. Example:
game.Players.PlayerAdded:connect(function(plyr) plyr.CharacterAdded:connect(function(char) --st00f end) end) |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2013 05:17 PM |
| Maybe you created the function wrong. |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 28 Feb 2013 05:37 PM |
Okay, thanks. That helped a lot! I tried making the jump part, and here is some of my code:
hit.Parent.Humanoid.Jumping:connect(jumping) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 12, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 12, 0) end
if jumping then while true do wait(0.1) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 12, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 12, 0) end else if not jumping then
while true do wait(0.2) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 1, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 1, 0) end
end
When I run it, it says "Attempt to call a nil value" but it doesn't say which line. Did I do everything right? |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2013 05:41 PM |
Line 3. Look in your script editor. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2013 05:43 PM |
Fixed it. It should be something like this:
hit.Parent.Humanoid.Jumping:connect(function(jumping) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 12, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 12, 0)
if jumping then while true do wait(0.1) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 12, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 12, 0) end else if not jumping then
while true do wait(0.2) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 1, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 1, 0) end
end end end)
|
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 28 Feb 2013 05:44 PM |
Well I have more script than this, line 3 is a wait(). If you're talking about line 3 of the code I posted, which is actually line 27, I see nothing wrong with it. You're talking about this line, right?
_G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 12, 0)
If you are, what's wrong with it? |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 28 Feb 2013 05:45 PM |
| I was replying to your first post. Thanks for the edited code, I'll take a look at it. |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 28 Feb 2013 06:48 PM |
I put in what you said, it fixed it, and I also changed a bit. Here is the new code:
hit.Parent.Humanoid.Jumping:connect(function(jumping) while jumping == true do wait(0.2) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 12, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 12, 0) end while jumping ~= true do wait(0.2) _G.footprint.CFrame = _G.leftleg.CFrame - Vector3.new(0, 1, 0) _G.footprint2.CFrame = _G.rightleg.CFrame - Vector3.new(0, 1, 0) end
end)
But now the footprints flash up and down because both of those happen at the same time. It's like I'm jumping and not jumping at the same time. Is the function wrong? |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2013 06:53 PM |
| The while true do is messing it up. |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 28 Feb 2013 06:56 PM |
| Oh. That makes sense. How would I fix it though? |
|
|
| Report Abuse |
|
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
|
| 28 Feb 2013 07:00 PM |
Nevermind. I changed it to while (jumping == true) do and it still messes up. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2013 08:45 PM |
Here's the base of the non bugged script idea:
game.Players.PlayerAdded:connect(function(plyr) plyr.CharacterAdded:connect(function(char) char["Right Leg"].Touched:connect(function(hit) if (hit.Name == "Sand") then wait() --st00f end end) end) end)
|
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 28 Feb 2013 08:53 PM |
| Try raycasting from the foot to the ground when jumping, or just don't make footprints... |
|
|
| Report Abuse |
|
|