I’m trying to add custom physical properties to a part that does not exist yet. The part is added using a script. The part in question is a sphere that the player is in. The player moves by rolling.
When I try to add the custom physical properties using a script the player can no longer move. This is the part of the script I’ve been using.
marble.CustomPhysicalProperties = true
marble.CustomPhysicalProperties.Density = 0.7
marble.CustomPhysicalProperties.Elasticity = 0.5
marble.CustomPhysicalProperties.ElasticityWeight = 1
marble.CustomPhysicalProperties.Friction = 1
marble.CustomPhysicalProperties.FrictionWeight = 3
The following script is the script I’m using to make the player a ball with the other part of the script.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local HRP = char:WaitForChild("HumanoidRootPart")
local marble = Instance.new("Part")
marble.Size = Vector3.new(8,8,8)
marble.BrickColor = BrickColor.Random(1)
marble.Transparency = .5
marble.Shape = Enum.PartType.Ball
marble.Parent = char
marble.Material = Enum.Material.SmoothPlastic
marble.CustomPhysicalProperties = true
marble.CustomPhysicalProperties.Density = 0.7
marble.CustomPhysicalProperties.Elasticity = 0.5
marble.CustomPhysicalProperties.ElasticityWeight = 1
marble.CustomPhysicalProperties.Friction = 1
marble.CustomPhysicalProperties.FrictionWeight = 3
local Velocity = Instance.new("BodyAngularVelocity")
Velocity.Parent = marble
local Hum = char:WaitForChild("Humanoid")
local Weld = Instance.new("Weld")
Weld.Parent = marble
Weld.Part0 = HRP
Weld.Part1 = marble
Hum.PlatformStand = true
while true do
wait()
marble.BodyAngularVelocity.AngularVelocity = Vector3.new(char.Humanoid.MoveDirection.z * 25,0,char.Humanoid.MoveDirection.x * -25)
marble.BodyAngularVelocity.MaxTorque = Vector3.new(500000,500000,500000)
if char.Humanoid.MoveDirection == Vector3.new(0,0,0) then
marble.BodyAngularVelocity.MaxTorque = Vector3.new(0,0,0)
end
end
end)
end)
Anybody know how I can make this work? When finding the part under my player model in workspace it does not have CustomPhysicalProperties enabled. I don’t know how I would do it by waiting for the part to be added because every player has a different username.