I Have A Question On A Movement Script For My Custom Model

I had made a custom model and wanted the player to become that custom model if they spawn on a certain team (by that I mean I am using a model from the toolbox and added joints, so it could be used as a character and be animated). The only problem I am trying to figure out is how I can give that player the ability to move with that custom model, since it is different from a normal character. I have looked online and the dev forum, but all I could find was how to clone a custom model for a certain team, or little primary part problems, etc. I am using a table to change the teams by the way, it is like the clown killing game, here is a link (The Clown Killings Reborn [NEW MAPS!] - Roblox).

Custom Model

KingBoo

Thanks For Reading! :grin: Articles and examples help a lot!

3 Likes

Have you looked at this Replacing the default character with a custom character?

Yes I have seen this and my custom model is a lot different from this, I am not quite sure how I am suppose to make it move for the player since it doesn’t have the necessary parts.

1 Like

So the new player get’s the new model but is unable to move around?

yes that is correct, the model has different parts then a normal character, so I need help on trying to figure out how to properly have it move. (btw I need to go for a little bit, so it might take me some time to respond).

Have a look at this then How to do custom character movement?
You would probably have to script the movement system for the new model.

1 Like

Could you give me a little explanation to help me understand how he constructed this? (I am new to it and this is a little hard to understand)

1 Like

I’m also pretty new to it but I’ll give you some general things in your code you have to setup. The first being a way to detect input from the user. This is done by detecting a keyboard press and checking what button has been pressed. depending on what button has been pressed you want to save that value to a variable. You will also have to create a function that detects when the user stops pressing a button to stop moving.

After this you can create a new function and bind it to the rendering of roblox by using
RunService:BindToRenderStep()
this function will use
Player:Move(Camera.lookVector * movez + Camera.rightVector * movex, true)
to move the player based on the current direction and angle.

local movements = {
    ["forw"] = Enum.KeyCode.W,
    ["left"] = Enum.KeyCode.A,
    ["back"] = Enum.KeyCode.S,
    ["righ"] = Enum.KeyCode.D,
}

local inputs = setmetatable({}, {
    __index = function(t, k)
        return game:GetService("UserInputService"):IsKeyDown(movements[k]) and 1 or 0
    end
})

local player = game:GetService("Players").LocalPlayer
local character = player.Character
local humanoid = character.Humanoid

game:GetService("RunService").RenderStepped:Connect(function()
	local movez = inputs.forw - inputs.back
	local movex = inputs.righ - inputs.left
	humanoid:Move(Vector3.new(0, 0, -movez) + Vector3.new(-movex, 0, 0), true)
end)

I only just noticed the :Move() method takes 2 arguments, moveDirection and relativeToCamera. I you have relativeToCamera set to to true you don’t need to mulitply by camera lookVectors and rightVector.

3 Likes

It works, but this keeps on happening, my model automatically moves by itself and doesn’t give me any control, do you have an answer for this? (sorry for the long wait).

Wait it is doing this without the script as well. (edit)
If you want, you can try out the model here to find out what is wrong: KingBooTest.rbxl (24.8 KB)

I FIGURED OUT THE PROBLEM! I had everything with cancollide marked as true when only the HumanoidRootPart should have that feature. Now I have to fix the movement b/c it is off on the rotation, thanks for all of the help!

3 Likes

Sorry to bump, but can you tell me what you did to fix the character always moving? My parts have cancollide off except hrp