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

The character is falling, as it hits the ground some parts should spawn, they spawn way above, why?

Asked by
Echtic 128
4 years ago

This is the script:

wait()

script.Parent.OnServerEvent:Connect(function(player)

    local character = player.Character
    local melee = player.PlayerStats.Melee.Value

    if character.HumanoidRootPart:FindFirstChild("BodyVelocity") ~= nil then
    character.HumanoidRootPart.BodyVelocity:Destroy()
    end

    local bdv = Instance.new("BodyVelocity",character.HumanoidRootPart)
    bdv.Name = "bdv"
    bdv.Velocity = Vector3.new(0,-90,0) * (melee/30 + 5)
    bdv.MaxForce = Vector3.new(99999,99999,99999)

    local td = game.ReplicatedStorage.Objects.TouchDetector2:Clone()
    td.Parent = character.HumanoidRootPart
        td.CFrame = character.HumanoidRootPart.CFrame

    local weld = Instance.new("Weld",td)
    weld.Part0 = td
    weld.Part1 = character.HumanoidRootPart

    td.Touched:Connect(function(hit)

        if hit.Anchored == true then




            character.HumanoidRootPart.Anchored = true

            td:Destroy()

            local cfr = character.LowerTorso.CFrame


            local cr = game.ReplicatedStorage.Objects["Cracks and rocks"]:Clone()
            wait()
            cr.Parent = character.LowerTorso
            cr.Size = Vector3.new((melee/5)+10,(melee/5)+10,(melee/5)+10)
            cr.CFrame = cfr





            wait(1)

            bdv.Velocity = Vector3.new(0,90,0)
    bdv:Destroy()
        character.HumanoidRootPart.Anchored = false



        end





    end)


end)

So the character is falling down faster than normal cause there's a body velocity making it go down. Now that part's CFrame should be the same as the HumanoidRootPart.CFrame as it hits the ground, but instead the CFrame of the part is well above the character. Any ideas how to fix that?

1
you should try to send the humanoidrootparts position from the client to the server with a remote event because in the server the player may have not landed yet fistter1 88 — 4y
0
So do i call the client, and then the server again or? Echtic 128 — 4y

Answer this question