Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Where does this LocalScript need tweaking ?

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.

1 answer

✓ Accepted answer

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

3 comments

0

Oh christ, as if I didn't notice that haha, well spotted dude, I fixed the spelling of line 38 but the problem's still there, when I press 'a', 'd' or 'w' to move the character, the character will neither move or jump , 'a' and 'd' are bound to right and left and 'w' is bound to jump but i'm still getting nothing

0

Also changed the spelling of character on line 33 as well, the error I get is : 17:25:23.162 - Getservice is not a valid member of DataModel

0

Aha! after also changing 'move' to 'Move' and 'Getservice' to 'GetService' the script works, I'll accept as answer as the solution lied in viewing the output section and checking it against the script, which you mentioned, thankyou!

This discussion is preserved as it was. New answers, comments, and votes are closed.