|
| 28 Aug 2015 08:40 PM |
I have a script inside of a part I named "Cube" in the workspace. There is a part attached to it with the name of the character. I'm trying to make a script that moves the cube around when someone pushes WASD. For some reason the script isn't working, any help?
script.Parent:WaitForChild("Name1") local cube = script.Parent local name1 = script.Parent.Name1
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then cube.CFrame = cube.CFrame + CFrame.new(0.1, 0, 0) name1.CFrame = cube.CFrame + CFrame.new(0.1, 0, 0) end if inputObject.KeyCode == Enum.KeyCode.S then cube.CFrame = cube.CFrame - CFrame.new(0.1, 0, 0) name1.CFrame = cube.CFrame - CFrame.new(0.1, 0, 0) end if inputObject.KeyCode == Enum.KeyCode.A then cube.CFrame = cube.CFrame - CFrame.new(0, 0, 0.1) name1.CFrame = cube.CFrame - CFrame.new(0, 0, 0.1) end if inputObject.KeyCode == Enum.KeyCode.A then cube.CFrame = cube.CFrame + CFrame.new(0, 0, 0.1) name1.CFrame = cube.CFrame + CFrame.new(0, 0, 0.1) end end)
|
|
|
| Report Abuse |
|
Robin5D
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 227 |
|
|
| 28 Aug 2015 08:48 PM |
Output say anything?
If not, this might work: script.Parent:WaitForChild("Name1") local cube = script.Parent local name1 = script.Parent.Name1
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W & script.Parent.name1.Value == "InsertNameHere" then then cube.CFrame = cube.CFrame + CFrame.new(0.1, 0, 0) name1.CFrame = cube.CFrame + CFrame.new(0.1, 0, 0) end if inputObject.KeyCode == Enum.KeyCode.S & script.Parent.name1.Value == "InsertNameHere" then then cube.CFrame = cube.CFrame - CFrame.new(0.1, 0, 0) name1.CFrame = cube.CFrame - CFrame.new(0.1, 0, 0) end if inputObject.KeyCode == Enum.KeyCode.A & script.Parent.name1.Value == "InsertNameHere" then cube.CFrame = cube.CFrame - CFrame.new(0, 0, 0.1) name1.CFrame = cube.CFrame - CFrame.new(0, 0, 0.1) end if inputObject.KeyCode == Enum.KeyCode.A & script.Parent.name1.Value == "InsertNameHere" then cube.CFrame = cube.CFrame + CFrame.new(0, 0, 0.1) name1.CFrame = cube.CFrame + CFrame.new(0, 0, 0.1) end end)
|
|
|
| Report Abuse |
|