How do I make a player marble

Hello, I’m trying to make a marble ball similar to super blocky ball for a marble platformer game but I can’t figure out how.

While there is another post similar to this but it wasn’t very helpful so I was wondering if I could have some help.

6 Likes

What do you mean “player marble”. Is that like a rolling ball that the player is in?

The post isn’t very clear.

1 Like

Yes that’s what I meant by the title sorry for the confusion.

1 Like

Well thanks for the clarification.

I’d suggest using a weld and using a bodyForce on the weld. I believe there is a pretty useful devforum post here, it could help out!

For more information on bodyForces, check out this page on it.

1 Like

Ok so how do I weld it to the player.

With a weld?

It’s pretty simple, look at this post on the dev hub to understand it.

1 Like

Something along the lines of this:

local Character = workspace.Player -- this is most definitely not how you get a player's character, this is just for the sake of pseudo code
local Marble = workspace.Part -- I assume you won't be retrieving the marble this way, so retrieve it from whichever directory

function Weld()
    Marble.CFrame = Character.HumanoidRootPart.CFrame

    local MarbleWeld = Instance.new("ManualWeld")
    MarbleWeld.C0 = Character.HumanoidRootPart.CFrame
    MarbleWeld.C1 = Marble.CFrame
    MarbleWeld.Part0 = Character.HumanoidRootPart
    MarbleWeld.Part1 = Marble
    MarbleWeld.Parent = Character.HumanoidRootPart
end

Weld()

That’s the gist of how welding works, but you’ll need to modify it to your needs.

1 Like

Screenshot_194
Is this how I make the code since I’m not sure if I’m doing it right.

You can only retrieve the LocalPlayer from a LocalScript, by the way. Also, to get the actual Character model in workspace, you’ll need to use this line of code instead:

local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

The .CharacterAdded:Wait() event can be unnecessary or necessary depending on your usage of the marbles. Also, I recommend utilizing the :GetService() function to retrieve the Players service. It’s a good practice as opposed to retrieving it from game.

1 Like

The player keeps on spawning on the outside of the marble no matter what I do

1 Like
local function WeldTwoParts(A, B)
   local weld = Instance.new("WeldConstraint")
   weld.Parent = workspace
   weld.Part0 = A
   weld.Part1 = B
end

local Player = game.Players.LocalPlayer
local Character = Player.Character
if not Character or not Character.Parent then
   Character = Player.CharacterAdded:wait()
end
local HRP = Character.HumanoidRootPart
local Marble = workspace.Marble

wait(5)
character:SetPrimaryPartCFrame(Marble.CFrame)
WeldTwoParts(HRP, Marble)

@funkmeist123, this make that the Character of the Player, the Player, wait 5 seconds and then teleport the Player into your MarbleBall and Weld it together.

2 Likes

Question, is this a script or a localscript also where do I place it?

1 Like

This is a Local Script, put it in StarterPlayerScripts or StarterGui or something else.

1 Like

Where should I put the marble block? also, what do the A and B do?
I also found this error in output.


@Eternalove_fan32

1 Like

Ok, A and B are Parameters. You can remplace A with Player Character and B wih your Marble Block. And you should put the marble ball in the WORKSPACE. Try this new LocalScript:

local Player = script.Parent.Parent or game.Players.LocalPlayer
local Character = Player.Character
local HRP = Character.HumanoidRootPart
local Marble = workspace.Marble

local function WeldTwoParts(A, B)
   local weld = Instance.new("WeldConstraint")
   weld.Parent = workspace
   weld.Part0 = A
   weld.Part1 = B
end
wait(5)
Character:SetPrimaryPartCFrame(Marble.CFrame)
WeldTwoParts(HRP, Marble)

The misstake i made was to write Character with a lowercase (bad english, sorry), this should work

1 Like

Sorry to bother you again but nothing really changed with the new script it still refuses to work, it also sends me the same error message in output.

1 Like

Number of the Line pls? Without this i cant help.

1 Like

Ok, it’s at line 3 in the code.

1 Like

Ok, can you pls wait a bit?wait

1 Like

Ok, try with this (THIS IS A SERVERSCRIPT, ALIAS SCRIPT):

game.Players.PlayerAdded:Connect(funtion(player)
    player.CharacterAdded:Connect(function(character)
     local Marble = workspace.Marble
     local function WeldTwoParts(A, B)
        local weld = Instance.new("WeldConstraint")
        weld.Parent = workspace
        weld.Part0 = A
        weld.Part1 = B
     end
     wait(5)
     Character:SetPrimaryPartCFrame(Marble.CFrame)
     WeldTwoParts(character.HumanoidRootPart, Marble)
   end)
end)

@funkmeist123, put it into the ServerScriptStorage or something else.

1 Like