Hello There,
In the script I have in this post what I’m trying to do is when the player hit the part the script calculates the players speed to KM/H but I tried some many times and I can’t get it to calculate the players speed.
Script
local Players = game:GetService("Players")
local speedLimit = script.Parent.Parent.Parent:WaitForChild("SpeedLimit")
local Gui = script:WaitForChild("Ticket")
debounce = false
print(speedLimit.Value.."kph | Has Been Set for Andover Speed Camera")
script.Parent.Touched:Connect(function(hit)
if debounce == false then
debounce = true
local player = hit.AssemblyLinearVelocity.Magnitude
if hit.Parent:FindFirstChild("Humanoid") then
if (math.floor(hit.AssemblyLinearVelocity.Magnitude)) >= speedLimit.Value then
local player = Players:FindFirstChild(hit.Parent.Name)
print("Players Speed before they get a ticket "..math.floor(hit.AssemblyLinearVelocity.Magnitude))
if hit.AssemblyLinearVelocity.Magnitude >= speedLimit.Value then
local clone = Gui:Clone()
clone.Parent = player.PlayerGui
player.leaderstats.Pounds.Value = player.leaderstats.Pounds.Value - 100
player.leaderstats.Bounty.Value = player.leaderstats.Bounty.Value + 15
wait(2)
clone:Destroy()
else
end
end
end
debounce = false
end
end)
If someone can help me calculate the players speed that would be great.