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 » Game Design
Home Search
 

Onkey Help

Previous Thread :: Next Thread 
J3Z1 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. J3Z1
Joined: 27 Dec 2014
Total Posts: 49
29 Jul 2015 04:02 AM
necrobump. Still need help with this.
Report Abuse
J3Z1 is not online. J3Z1
Joined: 27 Dec 2014
Total Posts: 49
29 Jul 2015 07:32 PM
necrobump. STILL need help with this.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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