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

How would I make kill logs with studs for swords? Help if you can.

Asked by
Fako16 13
5 years ago

As many of you might know there's a dedicated sword-fighting community which uses swords as it's weapon similiar to the gun-fighting community, but there's a problem in the sword-fighting community, people can use exploits and lag to their benefit, recently I saw in one of the groups I am in for sword-fighting that they have kill logs, which show the studs for every kill, this is very important as the normal acceptable studs for a kill are 7-9 studs, anything bigger than this can mean exploits or severe lag. Could anyone show me how to start off making kill logs for this? It'd really help me out and it'd be a good way to get rid of exploiters in the community.

Thanks for anyone who tries to help, really means alot. Fako16

0
In more detail, I want to know how to calculate the studs between two players when a kill occurs. Thanks. Fako16 13 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Assuming that there are only two players in close combat (what I mean by this is there can't be three people all in close proximity fighting each other), you can connect the :Died() event from the humanoid to check how far the closest player in. That script would look something like this:

local ShortestDist = 5000 -- This has to be big to start
local ClosestPlayer = nil

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:WaitForChild("Humanoid").Died:Connect(function(hum)
            for i, player in pairs(game.Players:GetPlayers() do
                if workspace:FindFirstChild(player.Name) then
                    if ShortestDist > (char.HumanoidRootPart.Position - workspace[player.Name].Position).magnitude then
                        ShortestDist = (char.HumanoidRootPart.Position - workspace[player.Name].Position).magnitude

                    end 

                    -- use the value we just got for the distance
                    ShortestDist = 5000 -- set it back to 5000
                end
            end
        end)
    end)
end)

I recommend opening the source to read this script. Hope I helped.

-Cmgtotalyawesome

Ad

Answer this question