Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a part spawn directly below player?

Asked by 2 years ago

I'm making an ice trail which spawns on the players leftlowerleg (the ice trails is an instance of both a part and a particle), but I'm having a problem with getting it directly below the leftlowerleg, instead it decides to spawn behind the leg and I'm not sure how to fix this. Here's a video to show it, and my code: https://gyazo.com/c1c72e68015ed43982228d1ccea61fe2

TrailEvent.OnServerEvent:Connect(function(player)
    local Character = player.Character
    local leftLeg = Character:FindFirstChild("LeftLowerLeg")
    local h = Character.Humanoid
    h.WalkSpeed = 50
    while h.MoveDirection ~= Vector3.zero do
        local Trail = Instance.new("Part")
        local Particle = Instance.new("ParticleEmitter")
        local colorKeypoints = {
            ColorSequenceKeypoint.new( 0, Color3.new(0.607843, 0.760784, 1)),  
            ColorSequenceKeypoint.new(.5, Color3.new(0.705882, 0.839216, 1)), 
            ColorSequenceKeypoint.new( 1, Color3.new(1, 1, 1))   
        }
        local numberKeypoints2 = {
            NumberSequenceKeypoint.new(0, 0);  
            NumberSequenceKeypoint.new(1, 10); 
        }
        Particle.Parent = Trail
        Particle.Color = ColorSequence.new(colorKeypoints)
        Particle.LightInfluence = 1
        Particle.Texture = "rbxassetid://3916143220"
        Particle.Transparency = NumberSequence.new(0.5,0.5)
        Particle.Lifetime = NumberRange.new(2.5,2.5)
        Particle.Enabled = true
        Particle.Size = NumberSequence.new(numberKeypoints2)
        Particle.LockedToPart = true
        Particle.Speed = NumberRange.new(1,1)
        Particle.Rate = 8
        Particle.TimeScale = 1
        Trail.Transparency = 0.2
        Trail.BrickColor = BrickColor.new("Baby blue")
        Trail.Material = Enum.Material.Neon
        Trail.Size = Trail.Size + Vector3.new(4,0,10)
        Trail.Anchored = true
        print("left leg is moving")
        Trail.Parent = leftLeg
        Trail.Position = leftLeg.Position 
        wait()
    end
end)

1 answer

Log in to vote
0
Answered by 2 years ago

Yes roblox can be buggy sometimes but you can just do

Trail.Position = Character.HumanoidRootPart.Position - Vector3.new(0,10,0)

You can tweak the Y Axis on Vector3.new to be lower or to be higher

Ad

Answer this question