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

[SOLVED] BodyVelocity works in my previous scripts, but when I try to do it again it doesn't?

Asked by 5 years ago
Edited 5 years ago

So, from my understanding of BodyVelocity, they add to the velocity of their parent part until the parent part has the same velocity as the BodyVelocity. When making a fire ball script, this BodyVelocity works just fine and launches the fire ball, but when I try to make a wave, it's like the wave just completely ignores the BodyVelocity's existance.

Wave Script:

-- Replicated Storage

local repStorage = game:GetService("ReplicatedStorage")

local powers = repStorage.Powers

local water = powers.Water



local r = water.R

local t = water.T

local v = water.V



-- Events

r.OnServerEvent:Connect(function(player,mousehit)

    -- Character Stuff

    local char = player.Character

    local hum = char.Humanoid

    local root = char.HumanoidRootPart

    -- Stats

    local stats = player.Stats

    local power = stats.Power

    local powerLevel = power.PowerLevel

    -- Meshes

    local mesh = script.Wave:Clone()

    mesh.Size = Vector3.new(powerLevel.Value/15+10,powerLevel.Value/15+10,powerLevel.Value/10+25)

    mesh.Parent = game.Workspace

    mesh.CFrame = CFrame.new(root.Position,mousehit.p)

    mesh.Orientation = Vector3.new(0,mesh.Orientation.Y,0)

    local bv = Instance.new("BodyVelocity",mesh)

    bv.Velocity = (mousehit.p-root.Position).Unit*200

    bv.Velocity = Vector3.new(bv.Velocity.X,0,bv.Velocity.Z)

    mesh.Velocity = bv.Velocity

    wait(5)

    mesh:Destroy()

end)

Fire Ball Script:

-- Meshes

local explosion = script:WaitForChild("Explosion")

local magma = script:WaitForChild("Magma")

local fireBall = script:WaitForChild("FireBall")



local fireEvents = game.ReplicatedStorage:WaitForChild("Powers"):WaitForChild("Fire")

local fireEvent = fireEvents:WaitForChild("Fire")

local onDead = fireEvents:WaitForChild("OnDead")



-- Variables

local multiplier = 1.5

local whenHit = require(script.Parent["Module Scripts"].WhenHit)



-- Other

local tweenService = game:GetService("TweenService")



fireEvent.OnServerEvent:Connect(function(player,key,mousePose,mouseTarget)

    local char = game.Workspace[player.Name]

    local rootPart = char.HumanoidRootPart

    local humanoid = char.Humanoid

    local stats = player.Stats

    local power = stats.Power

    local powerLevel = power.PowerLevel

    if key == Enum.KeyCode.R then

        local rightHand = char.RightHand

        -- Fire Ball

        local fireBallc = fireBall:Clone()

        fireBallc.Parent = game.Workspace

        fireBallc.CFrame = rightHand.CFrame

        -- Body Velocity

        local bv = Instance.new("BodyVelocity",fireBallc)

        bv.Velocity = (mousePose.p-rightHand.Position).Unit*200

        fireBallc.Velocity = bv.Velocity

        local db1 = false

        fireBallc.Touched:Connect(function(hit)

            local canExplode = true

            for i,v in pairs(char:GetChildren()) do

                if hit == v then

                canExplode = false

            end

            for i,b in pairs(v:GetChildren()) do

                if hit == b then

                canExplode = false

            end

        end

        end

        if not canExplode or db1 or hit ~= mouseTarget then return end

        db1 = true

        local explosionC1 = explosion:Clone()

        local explosionC2 = explosion:Clone()

        explosionC1.Parent = game.Workspace

        explosionC2.Parent = game.Workspace

        explosionC1.Color = Color3.fromRGB(255,math.random(150,255))

        explosionC2.Color = Color3.fromRGB(255,math.random(150,255))

        explosionC1.CFrame = mousePose * CFrame.Angles(math.random(0,360),math.random(0,360),math.random(0,360))

        explosionC2.CFrame = mousePose * CFrame.Angles(math.random(0,360),math.random(0,360),math.random(0,360))

        -- Damage

        for i,v in pairs(game.Workspace:GetChildren()) do

            if v == explosionC2 then

                local db = false

                local ignored = {}

                v.Touched:Connect(function(hit)

                    if not db and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= player.Name then

                        db = true

                        local isIgnored = false

                        local number = 1

                        local Character = hit.Parent

                        for i,ignor in pairs(ignored) do

                            if ignor == Character then

                            isIgnored = true

                        end

                        if not isIgnored then

                            number = number + 1

                        end

                    end

                    local blocking

                    if Character:FindFirstChild("StatsStuffs") then

                    blocking = Character.StatsStuffs.BlockEnabled

                    end

                    local didHurt = false

                    local damage

                    if not isIgnored then

                    table.insert(ignored,Character)

                    whenHit.tagged(hit,player)

                    local dmg = (powerLevel.Value*2)+math.random(20,30)

                    if blocking and blocking.Value then

                    damage = whenHit.ifBlocking(hit,dmg,player)

                    else

                    damage = dmg

                    end

                    local hum = hit.Parent.Humanoid

                    hum:TakeDamage(damage)

                    didHurt = true

                    end

                    db = false

                    if damage then

                    whenHit.dmgGui(hit,damage)

                    end

                    if didHurt then

                    whenHit.burn(hit,powerLevel.Value/2 + math.random(1,5),1)

                    end

                    end

                end)

            end

        end

        fireBallc:Destroy()

        db1 = false

        local tweenInfo = TweenInfo.new(

        1, -- Time

        Enum.EasingStyle.Sine, -- Style

        Enum.EasingDirection.InOut, -- Direction

        0, -- Repeat Times

        false, -- Should Repeat

        0 -- Repeat Delay

        )

        local partProperties = {

        Size = Vector3.new(powerLevel.Value/4+75,powerLevel.Value/4+75,powerLevel.Value/4+75);

        Transparency = 1;

        Color = Color3.fromRGB(0,0,0)

        }

        local tween1 = tweenService:Create(explosionC1,tweenInfo,partProperties)

        local tween2 = tweenService:Create(explosionC2,tweenInfo,partProperties)

            tween1:Play()

            tween2:Play()

            wait(1)

            explosionC1:Destroy()

            explosionC2:Destroy()

        end)
end

Note: * Both scripts are server scripts triggered by local scripts. * The wave script isn't finished yet, so it doesn't show damage.

Edit: I did some testing around, and I found out that the size of the mesh is what caused the fire ball to work but not the wave, but how would I make it work with the wave too?

Edit 2: I noticed that by upping the MaxForce property of the BodyVelocity, it allowed the heavier meshes to move as I wanted them to. I will keep this question here in case anyone else has this issue, but as of right now, I've figured it out.

0
Please. Why are you adding a line of space after each line. This is messy. User#24403 69 — 5y
0
that always happen when you add something to a block in here incapaxx Gameplayer365247v2 1055 — 5y
0
Yeah, they changed the typing system thing, so now it's very awkward to post scripts because when I copy them and paste them, it adds line spacing and doesn't indent right. Knineteen19 307 — 5y
0
Although I'm sure you can at least manage to read it, it's not that bad. If you don't feel like helping, I get it, but don't come here to judge people about things you don't know. Knineteen19 307 — 5y

Answer this question