--mayo's pedal script

local mouse = game.Players.LocalPlayer:GetMouse()
local car = script.Parent.Car.Value
local handler = car:WaitForChild("PedalsFE")

script.Parent.Values.Throttle.Changed:connect(function()
	local gas = script.Parent.Values.Throttle.Value^1*math.rad(32)
	handler:FireServer("PedalUpdate","Gas",gas)
end)

script.Parent.Values.Brake.Changed:connect(function()
	local bp = script.Parent.Values.Brake.Value^1*math.rad(26)
	handler:FireServer("PedalUpdate","Brake",bp)
end)

script.Parent.Values.Gear.Changed:connect(function()
	handler:FireServer("PedalUpdate","Clutch",0.55)
end)

script.Parent.Values.PBrake.Changed:connect(function()
	if script.Parent.Values.PBrake.Value == true then
		handler:FireServer("PBrake")
	end
end)

script.Parent.Values.Gear.Changed:connect(function()
	if script.Parent.Values.Gear.Changed then
		handler:FireServer("Pedal")
		wait(.15)
		handler:FireServer("Shift")
	end
end)

mouse.KeyDown:connect(function(key)
	if script.Parent.Values.MouseSteerOn.Value == false and key=="w" then
		handler:FireServer("Pedal")
	end	
end)

mouse.KeyDown:connect(function(key)
	if script.Parent.Values.MouseSteerOn.Value == false and key=="s" then
		handler:FireServer("Pedal")
	end
end)

mouse.Button1Down:connect(function()
	if script.Parent.Values.MouseSteerOn.Value == true then
		handler:FireServer("Pedal")
	end	
end)

mouse.Button2Down:connect(function()
	if script.Parent.Values.MouseSteerOn.Value == true then
		handler:FireServer("Pedal")
	end
end)
