Help with my Script

Hi there, I want that in my game players are not the standard character model I want that players are rolls. what is wrong with my script that the player can not roll over the baseplate like I want it to be??

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")

-- Entferne Standard-Charakterteile
for _, part in pairs(character:GetChildren()) do
    if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
        part.Transparency = 1
        part.CanCollide = false
    end
end

-- Erstelle den Zylinder
local cylinder = Instance.new("Part")
cylinder.Shape = Enum.PartType.Cylinder
cylinder.Size = Vector3.new(4, 2, 4) -- Startgröße des Zylinders
cylinder.Anchored = false
cylinder.CanCollide = false
cylinder.Material = Enum.Material.SmoothPlastic
cylinder.BrickColor = BrickColor.new("Bright blue")
cylinder.Parent = character
cylinder.CFrame = hrp.CFrame

-- Synchronisiere Zylinder mit HumanoidRootPart
game:GetService("RunService").RenderStepped:Connect(function()
    cylinder.CFrame = hrp.CFrame
end)

-- Steuerung für Bewegung
local speed = 16 -- Bewegungsgeschwindigkeit
local moveDirection = Vector3.zero
local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end

    if input.KeyCode == Enum.KeyCode.W then
        moveDirection += Vector3.new(0, 0, -1)
    elseif input.KeyCode == Enum.KeyCode.S then
        moveDirection += Vector3.new(0, 0, 1)
    elseif input.KeyCode == Enum.KeyCode.A then
        moveDirection += Vector3.new(-1, 0, 0)
    elseif input.KeyCode == Enum.KeyCode.D then
        moveDirection += Vector3.new(1, 0, 0)
    end
end)

UserInputService.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.S then
        moveDirection = Vector3.new(moveDirection.X, 0, 0)
    elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
        moveDirection = Vector3.new(0, 0, moveDirection.Z)
    end
end)

game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
    local velocity = moveDirection * speed * deltaTime
    hrp.CFrame = hrp.CFrame + velocity
end)

1 Like

its better to make a custom character by changing the default character that roblox will load

you can do that by adding a model to StarterPlayer named StarterCharacter

image

also, the cylinder has to be manually rotated in the script

if you want to remove friction from the character you can follow the character controller tutorial or connect this function to Player.CharacterAdded

edit: you also have to turn off Humanoid.EvaluateStateMachine

function initialize(character)

	local cm = Instance.new("ControllerManager")
	local gc = Instance.new("GroundController", cm)
	Instance.new("AirController", cm)
	Instance.new("ClimbController", cm)
	Instance.new("SwimController", cm)
	
	cm.ActiveController = gc
	
--these control ground friction. higher frictionWeight = less friction
	gc.Friction = 0
	gc.FrictionWeight = 3

	local humanoid = character.Humanoid
	cm.RootPart = humanoid.RootPart
	gc.GroundOffset = humanoid.HipHeight + 0.5
	cm.FacingDirection = cm.RootPart.CFrame.LookVector

	local floorSensor = Instance.new("ControllerPartSensor")
	floorSensor.SensorMode = Enum.SensorMode.Floor
	floorSensor.SearchDistance = gc.GroundOffset + 2
	floorSensor.Name = "GroundSensor"

	local ladderSensor = Instance.new("ControllerPartSensor")
	ladderSensor.SensorMode = Enum.SensorMode.Ladder
	ladderSensor.SearchDistance = 1.5
	ladderSensor.Name = "ClimbSensor"

	local waterSensor = Instance.new("BuoyancySensor")

	cm.GroundSensor = floorSensor
	cm.ClimbSensor = ladderSensor

	waterSensor.Parent = cm.RootPart
	floorSensor.Parent = cm.RootPart
	ladderSensor.Parent = cm.RootPart
	cm.Parent = character

end
1 Like

it don’t has worked I don’t understand how to do it. and where the script should be now etc

I really don’t understand this😔

1 Like