of     1   

Geckoco
#183544927Sunday, February 14, 2016 12:20 AM GMT

I am trying to do x=something with a gui where you press w the sprite moves up. My script: for Key="w" do script.Parent.chatFrame.chatFrame.Sprite.Position=script.Parent.chatFrame.chatFrame.Sprite.Position-UDim2.new(0,0 , .01,0) end I love JSON! (Nope I hate it...)
Geckoco
#183545206Sunday, February 14, 2016 12:23 AM GMT

Woops old code: new code #Code while Key=="w" do wait() script.Parent.chatFrame.chatFrame.Sprite.Position=script.Parent.chatFrame.chatFrame.Sprite.Position-UDim2.new(0,0 , .01,0) end I love JSON! (Nope I hate it...)
cody123454321
#183545437Sunday, February 14, 2016 12:26 AM GMT

Key probs isn't defined in the script, nor does it equal w. Try (in a locascript): #Code local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local Sprite = script.Parent.chatFrame.chatFrame.Sprite Mouse.KeyDown:connect(function(key) if(key == "w")then Sprite.Position = Sprite.Position - UDim2.new(0, 0, .01, 0) end end)
Geckoco
#183545958Sunday, February 14, 2016 12:33 AM GMT

It is called its within a function I know what im doing. Just the new script will make it go forever up I love JSON! (Nope I hate it...)
LordDamionDevil
#183546488Sunday, February 14, 2016 12:40 AM GMT

LordDamionDevil
#183546604Sunday, February 14, 2016 12:42 AM GMT

Basically this is what you are looking for function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then script.Parent.chatFrame.chatFrame.Sprite.Position=script.Parent.chatFrame.chatFrame.Sprite.Position-UDim2.new(0,0 , .01,0) end end end game:GetService("UserInputService").InputBegan:connect(onKeyPress)
Geckoco
#183546789Sunday, February 14, 2016 12:45 AM GMT

Yeah I had got that. I am looking for when the key is pressed and held down the sprite will move up. I love JSON! (Nope I hate it...)
Geckoco
#183547041Sunday, February 14, 2016 12:49 AM GMT

Bump I love JSON! (Nope I hate it...)
LordDamionDevil
#183547238Sunday, February 14, 2016 12:52 AM GMT

then yo uwant this: mouse = game.Players.LocalPlayer:GetMouse() holdingkey = false mouse.KeyDown:connect(function(key) if key == "c" then holdingkey = true while holdingkey do script.Parent.chatFrame.chatFrame.Sprite.Position=script.Parent.chatFrame.chatFrame.Sprite.Position-UDim2.new(0,0 , .01,0) end end end end) mouse.KeyUp:connect(function(key) if key == "c" then holdingkey = false end end)
LordDamionDevil
#183547300Sunday, February 14, 2016 12:53 AM GMT

oops forgot the change the c to w here: mouse = game.Players.LocalPlayer:GetMouse() holdingkey = false mouse.KeyDown:connect(function(key) if key == "w" then holdingkey = true while holdingkey do script.Parent.chatFrame.chatFrame.Sprite.Position=script.Parent.chatFrame.chatFrame.Sprite.Position-UDim2.new(0,0 , .01,0) end end end end) mouse.KeyUp:connect(function(key) if key == "w" then holdingkey = false end end)
cheesecake123456
#183547464Sunday, February 14, 2016 12:56 AM GMT

I think KeyDown and KeyUp are deprecated, try InputBegan/InputEnded/InputChanged
BanTech
#183547664Sunday, February 14, 2016 12:59 AM GMT

Option 1: set a variable to true, set a while variable do loop going, and set it to false when UserInputService.InputEnded is fired with key W. Option 2: UIS = game:GetService('UserInputService') function checkW() local keys = UIS:GetKeysPressed() for _, k in pairs() do if k.KeyCode.Name == "W" then return true end end return false end --inside your inputbegan handler while checkW() do --stuff end
cody123454321
#183547701Sunday, February 14, 2016 1:00 AM GMT

"while holdingkey do script.Parent.chatFrame.chatFrame.Sprite.Position=script.Parent.chatFrame.chatFrame.Sprite.Position-UDim2.new(0,0 , .01,0) end end" Don't you need a coroutine?

    of     1