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

Badge Awarded is Player is at Certain Velocity or Faster?

Asked by 9 years ago

Hey guys,

Basically, I need a script that award a player a badge is they hit a brick at a certain speed. This is what I got so far.

function OnTouch(part)
    if (part.Parent:FindFirstChild("Humanoid") ~= nil) and part.Parent:FindFirstChild("Humanoid").Parent.Torso.Velocity.magnitude / 1.45 > 252.5 then
        local p = game.Players:GetPlayerFromCharacter(part.Parent)
        if (p ~= nil) then
            print("Awarding BadgeID: " ..script.Parent.BadgeID.Value .. " to UserID: " .. p.userId)
            local b = game:GetService("BadgeService")
            b:AwardBadge(p.userId, script.Parent.BadgeID.Value)
        end
    end
end

script.Parent.Touched:connect(OnTouch)

It is broken and probably no-way near what I want. Can someone take a look at it and see where (And how far) I went wrong?

Cheers,

  • Michael

Answer this question