J3Z1
|
  |
| Joined: 27 Dec 2014 |
| Total Posts: 49 |
|
|
| 27 Jul 2015 08:59 PM |
Hey guys. I have a script (not mine) that orders the player to sit. The code is inside a localscript, and the animation addressed is in the workspace. Here's what the code looks like:
wait(.1) player = game.Players.LocalPlayer mouse = player:GetMouse()
Animating = false Anim = nil
function KeyPress(key) if key == "c" then if not Animating then Anim = player.Character.Humanoid:LoadAnimation(script.sit) Animating = true while wait(0.0) and Animating do Anim:Play(0,1,1) game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 wait(0.4) while wait(0.4) and Animating do Anim:Play(0,1,1) game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 wait(0.8) while wait(0.8) and Animating do Anim:Play(0,1,1) game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 wait(1000000000000.5) while wait(1000000000000.5) and Animating do Anim:Play(0,1,1) game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0 end end end end else Animating = false game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 Anim:Stop() Anim:Destroy() end end end mouse.KeyDown:connect(KeyPress)
Any help appreciated. |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 27 Jul 2015 09:18 PM |
local player=game.Players.LocalPlayer mouse=player:GetMouse()
mouse.KeyDown:connect(function(key) if (key=="c" and player.Character:findFirstChild("Humanoid") and (not player.Character.Humanoid.Sit) ) then player.Character["Humanoid"].Sit=true end) |
|
|
| Report Abuse |
|
|
J3Z1
|
  |
| Joined: 27 Dec 2014 |
| Total Posts: 49 |
|
|
| 27 Jul 2015 09:22 PM |
| That didn't work for me, Qorm. Although I think it may have something to do with where my localscript/anim are placed. Where should both of them be? |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 27 Jul 2015 09:25 PM |
| i forgot an end but i thought u would figure that............ |
|
|
| Report Abuse |
|
|
J3Z1
|
  |
| Joined: 27 Dec 2014 |
| Total Posts: 49 |
|
|
| 27 Jul 2015 09:29 PM |
| I added the end. still doesn't work. |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 27 Jul 2015 09:38 PM |
you have to make an onjoin script which puts it inside your character
example: if you put the script inside this script
local sitscript=script:WaitForChild("LocalScript")
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) x=sitscript:Clone(); x.Parent=player.Inventory end;end)
now just change the player variable on the other script to script.Parent.Parent |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 27 Jul 2015 09:39 PM |
| once again forgot a bracket to end function |
|
|
| Report Abuse |
|
|
J3Z1
|
  |
| Joined: 27 Dec 2014 |
| Total Posts: 49 |
|
|
| 27 Jul 2015 09:40 PM |
| i'm not a scripter so you may need to put that in laymans terms for me to understand it. |
|
|
| Report Abuse |
|
|
Qorm
|
  |
| Joined: 25 Jul 2010 |
| Total Posts: 1650 |
|
|
| 27 Jul 2015 09:42 PM |
1. make a normal script in workspace 2. put the code in the script 3. take the sit script and put it in the normal script |
|
|
| Report Abuse |
|
|
J3Z1
|
  |
| Joined: 27 Dec 2014 |
| Total Posts: 49 |
|
|
| 27 Jul 2015 09:51 PM |
Okay. Currently I have one parent script with this code in it:
local sitscript=script:WaitForChild("LocalScript")
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) x=sitscript:Clone(); x.Parent=player.Inventory
end
-------------------------------------
And then I have a child localscript with this code in it:
local player=game.Players.LocalPlayer mouse=player:GetMouse()
mouse.KeyDown:connect(function(key) if (key=="c" and player.Character:findFirstChild("Humanoid") and (not player.Character.Humanoid.sit) ) then player.Character["Humanoid"].sit=true end
end
-------------------------------------
The script is in workspace and i'm still not getting anything out of it. |
|
|
| Report Abuse |
|
|
J3Z1
|
  |
| Joined: 27 Dec 2014 |
| Total Posts: 49 |
|
|
| 29 Jul 2015 04:02 AM |
| necrobump. Still need help with this. |
|
|
| Report Abuse |
|
|
J3Z1
|
  |
| Joined: 27 Dec 2014 |
| Total Posts: 49 |
|
|
| 29 Jul 2015 07:32 PM |
| necrobump. STILL need help with this. |
|
|
| Report Abuse |
|
|