Hey scripting wizards out there, I'm attempting to perhaps add to A 2D movement system, More specifically, the one provided on the Roblox wiki website (Source: http://wiki.roblox.com/index.php?title=Making_a_2D_Platformer)
It consists of two Local Scripts one named, 'CameraScript' and another named 'ControlScript' both under the parent 'StarterPlayerScripts'
The Camera side is working perfectly fine on my end however the Control side is not for some reason.
I'm pressing the allocated keys bound to the movement options within the script and there's no movement, the avatar is literally just standing there and won't move when the key is pressed.
Here is the base code they have provided in case the link is bugged and also to save time
local player = game.Players.LocalPlayer local RunService = game:GetService('RunService') local ContextActionService = game:Getservice('ContextActionService') local jumping = false local leftValue, rightValue =0,0 local function onLeft(actionName, inputState) if inputState == Enum.UserInputState.Begin then leftValue = 1 elseif inputState == Enum.UserInputState.End then leftValue = 0 end end local function onRight(actionName, inputState) if inputState == Enum.UserInputState.Begin then rightValue = 1 elseif inputState == Enum.UserInputState.End then rightValue = 0 end end local function onJump(actionName, inputState) if inputState == Enum.UserInputState.Begin then jumping = true elseif inputState == Enum.UserInputState.End then jumping = false end end local function onUpdate() if player.Character and player.Chracter:FindFirstChild('Humanoid') then if jumping then player.Character.Humanoid.Jump= true end local moveDirection = rightValue - leftValue player.Character.Huamnoid:move(Vector3.new(moveDirection,0,0), false) end end RunService:BindToRenderStep('Control', Enum.RenderPriority.Input.Value, onUpdate) ContextActionService:BindAction('Left', onLeft, true, 'a', Enum.KeyCode.Left, Enum.KeyCode.DPadLeft) ContextActionService:BindAction('Right', onRight, true, 'd', Enum.KeyCode.Right,Enum.KeyCode.DPadRight) ContextActionService:BindAction('Jump', onJump, true, 'w', Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
I'm trying to learn the intricacies of how these types of scripts can be adapted on for different gameplay mechanics, testing the waters for what works and what doesn't but not being able to get a baseline understanding of getting this here script to work severely hampers my efforts if you can see what I'm talking about.
Any help ASAP is much appreciated :)
[Update] The error message I get from the Output is;
17:25:23.162 - Getservice is not a valid member of DataModel
[Update] The problem's now solved and the script is functioning properly, moral of the story: always double check spelling and grammar.
You've spelt humanoid wrong on line 38
player.Character.Huamnoid:move(Vector3.new(moveDirection,0,0), false)
should be
player.Character.Humanoid:move(Vector3.new(moveDirection,0,0), false)
You should always check the output. You will probably have some kind of message that says Huamnoid is not a valid member of Character