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

Is the a way to prevent a grenade from bouncing too much?

Asked by 6 years ago

When I make a grenade the projectile bounces too much when it hits the ground. If I decrease the velocity of it, it still bounces and can't go as far. Is there a way to stop it from bouncing too much?

script.Parent.Parent:WaitForChild("Events").ThrowEvent.OnServerEvent:Connect(function(player, weapon, target)
    local grenade = script.Parent.Parent.Handle:Clone()
    grenade.CFrame = CFrame.new(grenade.CFrame.p, target)
    grenade.Velocity = grenade.CFrame.LookVector * 200
    grenade.Parent = workspace
    grenade.Anchored = false
    grenade.CanCollide = true
    game:GetService("Debris"):AddItem(grenade, 60)
    script.Parent.Parent.Handle.Transparency = 1
    wait(3)

    script.Parent.Parent.Handle.Transparency = 0
    grenade:Destroy()   
    local explosion = Instance.new("Explosion", workspace.Baseplate)
    explosion.BlastPressure = 0
    explosion.BlastRadius = 8
    explosion.ExplosionType = Enum.ExplosionType.NoCraters
    explosion.Position = grenade.Position
    explosion.Hit:Connect(function(part, distance)
        local humanoid = part.Parent:FindFirstChild("Humanoid")
        if humanoid and not debounce then
            debounce = true
            humanoid:TakeDamage(115 - (distance * 5))
            if humanoid.Health <= 0 and game:GetService("ReplicatedStorage").Gamemode.Value == "Team Deathmatch" then
                player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1
                player.leaderstats.Streak.Value = player.leaderstats.Streak.Value + 1   
                game:GetService("ReplicatedStorage").ScoreValues[player.Team.Name.."ScoreValue"].Value = game:GetService("ReplicatedStorage").ScoreValues[player.Team.Name.."ScoreValue"].Value + 1             
            end
            wait(math.huge)
            debounce = false
        end 
    end)
end)
0
why do you wait math.huge seconds to set debounce to false. But you can use a BodyForce with negative force on the Y axis so it's forced downwards User#19524 175 — 6y
1
YOOOOOOOOOOOOO ROBOT KILLER IS BACK LETS GOOOOO WELCOME BACK :D greatneil80 2647 — 6y

1 answer

Log in to vote
0
Answered by 4 years ago

probably set its custom phyisical properties so that its elasticity is like 0 https://developer.roblox.com/en-us/api-reference/datatype/PhysicalProperties

Ad

Answer this question